Skip to content
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

Publishing more than one port range with automatically assigned ports leads to port mapping conflict #8651

Closed
znerol opened this issue Dec 8, 2020 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@znerol
Copy link

znerol commented Dec 8, 2020

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Using the --publish flag it is possible to either specify the host port range explicitly or omit it. In the latter case the container runtime will allocate a random port range. If multiple --publish flags are used with multiple port ranges with host port range omitted, the container fails to start.

Steps to reproduce the issue:

  1. Run a container and specify more than one port range without explicit host port range mapping.
    podman run --rm --publish 3000-3001 --publish 4000-4001 k8s.gcr.io/pause
    

Describe the results you received:

Error: conflicting port mappings for host port 1 (protocol tcp)

Describe the results you expected:

Container starting with two random host port ranges allocated to the container port ranges.

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Reproducible with both 2.2.1 and master branch

podman version
Version:      2.2.1
API Version:  2.1.0
Go Version:   go1.14
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64
./bin/podman version
Version:      3.0.0-dev
API Version:  3.0.0
Go Version:   go1.14.10
Git Commit:   47d2a4be2af5143c9619a65ec641daa1025130a3
Built:        Tue Dec  8 21:47:44 2020
OS/Arch:      linux/amd64

Output of podman info --debug:

Very likely not relevant.

Package info (e.g. output of rpm -q podman or apt list podman):

compiled from source and installed from kubic

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.):

@mheon
Copy link
Member

mheon commented Dec 8, 2020

I think #8652 will also fix this one, let me add a test

mheon added a commit to mheon/libpod that referenced this issue Dec 9, 2020
The existing logic (Range > 0) always triggered, because range is
guaranteed to be at least 1 (a single port has a range of 1, a
two port range (e.g. 80-81) has a range of 2, and so on). As such
this could cause ports that had a host port assigned to them by
the user to randomly assign one instead.

Fixes containers#8650
Fixes containers#8651

Signed-off-by: Matthew Heon <mheon@redhat.com>
pmoogi-redhat pushed a commit to pmoogi-redhat/podman that referenced this issue Dec 15, 2020
The existing logic (Range > 0) always triggered, because range is
guaranteed to be at least 1 (a single port has a range of 1, a
two port range (e.g. 80-81) has a range of 2, and so on). As such
this could cause ports that had a host port assigned to them by
the user to randomly assign one instead.

Fixes containers#8650
Fixes containers#8651

Signed-off-by: Matthew Heon <mheon@redhat.com>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

3 participants