Code Monkey home page Code Monkey logo

Comments (6)

sshnaidm avatar sshnaidm commented on May 24, 2024 1

Yes, it's worth to mention in docs.

from ansible-podman-collections.

sshnaidm avatar sshnaidm commented on May 24, 2024

Seems like in podman 1.x versions the host port is random and in 2.x versions it's equal to container port. So in 1.x versions it will be like 3306:43728, while in 2.x it's 3306:3306. Need to workaround both versions.
Unfortunately it's impossible to know if 3306:43728 was set by user or it was random port, so the fix will be for 2.x versions only.

from ansible-podman-collections.

sshnaidm avatar sshnaidm commented on May 24, 2024

@roxifas ok, so after some clarifications in containers/podman#7947 we found out that if you set only one port 3360 it can be assigned to any random host port, for example 45362. The fact it's assigned to the same 3360 is actually a bug and will be fixed by containers/podman#7951 soon.
Given that, I'm not sure what is the point to set only one port? It will be assigned to random host port and we can't know what it can be.

from ansible-podman-collections.

roxifas avatar roxifas commented on May 24, 2024

Well that's good to know, I had actually started building my scripts with the thought that the port would be the same 🤔 I guess there are some usecases where people will want to have a random port, and they would have their containers constantly recreated by ansible. So perhaps the fix would be to ignore a non-matching host port if the ansible playbook has only the container port defined, because it means that the host port will be random anyway and should not be a reason to recreate the container. What do you think? @sshnaidm

from ansible-podman-collections.

sshnaidm avatar sshnaidm commented on May 24, 2024

@roxifas the problem in this case that we can't detect for sure was it random port assigned by podman or non-random port assigned by user. For example some user can assign - 3360:43234 and other user can do - 3360. In both cases in info it will be

"PortBindings": {
                "3360/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "43234"
                    }
                ]
            },

and no way to know if there is chosen by podman or user port.
The more I think about it the less I understand the logic behind the "randomness" of host port. But this is better to discuss in containers/podman#7947

from ansible-podman-collections.

roxifas avatar roxifas commented on May 24, 2024

If this information, about host port being random or not, is not stored anywhere, then this cannot really be fixed in the ansible module. It would be worth to mention this in the docs however, so that users do not get surprised by containers getting recreated unexpectedly.

from ansible-podman-collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.