-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When specifying one only container published port, the host port is not random but equal to containers one #7947
Comments
I'll take this one. |
@mheon is there a reason behind a "randomness" of host port? What is it useful for? Wouldn't be more logical to set the same port if only one port was configured (as it's behavior now in 2.x)? |
In Podman 1.9.3, `podman run -p 80` would assign port 80 in the container to a random port on the host. In Podman 2.0 and up, it assigned Port 80 in the container to Port 80 on the host. This is an easy fix, fortunately - just need to remove the bit that assumed host port, if not given, should be set to container port. We also had a test for the bad behavior, so fix it to test for the correct way of doing things. Fixes containers#7947 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
The logic, from what I can tell, is that this makes it trivial to launch a large batch of containers that all want to use the same port, and safely expose all of them to the internet. I could run a dozen HTTP servers with |
In Podman 1.9.3, `podman run -p 80` would assign port 80 in the container to a random port on the host. In Podman 2.0 and up, it assigned Port 80 in the container to Port 80 on the host. This is an easy fix, fortunately - just need to remove the bit that assumed host port, if not given, should be set to container port. We also had a test for the bad behavior, so fix it to test for the correct way of doing things. Fixes containers#7947 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
I only noticed b/c `podman-compose down` followed by `podman-compose up` broke my dev setup. So, the difference between `5432` and `5432:5432`: - `5432` instructs podman to pick an arbitrary port to map to a container's port `5432` - `5432:5432` instructs podman to map the host's port `5432` to a container's port `5432` podman v2.2.0+ ensures that the arbitrary port is random. See containers/podman#7947
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When specifying one only container published port -
--publish 9000
, the host port is not random but equal to containers one. In docs it's mentioned that host port will be a random port.Steps to reproduce the issue:
podman run -dit --name zzz -p 9000 alpine sleep 2m
podman inspect zzz
Describe the results you received:
Describe the results you expected:
I'd expect host port to be random as it's mentioned in documentation, like:
Additional information you deem important (e.g. issue happens only occasionally):
It happens in podman version 2, in podman versions 1 it's a real random port.
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
OS: Ubuntu 20.04
Related to issue of idempotency in ansible podman modules: containers/ansible-podman-collections#116
The text was updated successfully, but these errors were encountered: