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

Publish does not work after upgrade #6806

Closed
afbjorklund opened this issue Jun 28, 2020 · 7 comments · Fixed by #6808
Closed

Publish does not work after upgrade #6806

afbjorklund opened this issue Jun 28, 2020 · 7 comments · Fixed by #6808
Assignees
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

@afbjorklund
Copy link
Contributor

afbjorklund commented Jun 28, 2020

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

/kind bug

Description

It seems like something changed in the --publish syntax ?

--publish, -p=ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort

Publish a container's port, or range of ports, to the host.

Both hostPort and containerPort can be specified as a range of ports.

When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range.

It no longer seems to accept the ip::containerPort variant.

Steps to reproduce the issue:

  1. Use "podman run" with --publish parameteres

Describe the results you received:

$ sudo podman2 run --publish=127.0.0.1::8443 --publish=127.0.0.1::22 --publish=127.0.0.1::2376 --publish=127.0.0.1::5000 ubuntu:20.04
Error: must provide a non-empty container host port to publish

Describe the results you expected:

$ sudo podman1 run --publish=127.0.0.1::8443 --publish=127.0.0.1::22 --publish=127.0.0.1::2376 --publish=127.0.0.1::5000 ubuntu:20.04

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

Output of podman version:

1.8.2

2.0.0

Output of podman info --debug:

(paste your output here)

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

(paste your output here)

Additional environment details (AWS, VirtualBox, physical, etc.):

Ubuntu 20.04

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 28, 2020
@afbjorklund
Copy link
Contributor Author

As far as I can tell, it is either 7ac3d90 (or maybe 4e2a0b5)

Can't seem to find any unit tests for cmd/podman/common/util.go

@mheon
Copy link
Member

mheon commented Jun 28, 2020

Is that actually legal? Huh. Didn't think it was.

Should be a quick fix, let me grab this.

@mheon
Copy link
Member

mheon commented Jun 28, 2020

#6808 to fix

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Jun 28, 2020

Thanks! The idea is to pick a random port, where we are tunneling in those services:

  • 8443: minikube (custom variant, 6443 kubernetes)
  • 22: ssh
  • 2376: docker
  • 5000: registry
CONTAINER ID  IMAGE                                COMMAND  CREATED         STATUS             PORTS                                                                                                     NAMES
0a4c50ff1985  gcr.io/k8s-minikube/kicbase:v0.0.10           17 seconds ago  Up 17 seconds ago  127.0.0.1:41397->22/tcp, 127.0.0.1:35737->2376/tcp, 127.0.0.1:42677->5000/tcp, 127.0.0.1:36717->8443/tcp  crio

This for compatibility with both virtualbox (host-only network) and docker desktop VM

Otherwise one might as well have used the "front entrance" and used the CNI IP...

@mheon
Copy link
Member

mheon commented Jun 28, 2020

Reworked to choose a random port, thanks for pointing that out.

@skorhone
Copy link

@mheon Documentation should be updated to reflect this change. There's currently nothing about randomizing port for this operation.

There's also no mention, if you can specify combination of single container port and range of host ports. In this case, host port should be randomized from given range (if you wan't to follow docker's implementation)

@mheon
Copy link
Member

mheon commented Jun 29, 2020

I'll do the second bit in a separate PR.

mheon added a commit to mheon/libpod that referenced this issue Jun 29, 2020
I didn't believe that this was actually legal, but it looks like
it is. And, unlike our previous understanding (host port being
empty means just use container port), empty host port actually
carries the same meaning as `--expose` + `--publish-all` (that
is, assign a random host port to the given container port). This
requires a significant rework of our port handling code to handle
this new case. I don't foresee this being commonly used, so I
optimized having a fixed port number as fast path, which this
random assignment code running after the main port handling code
only if necessary.

Fixes containers#6806

Signed-off-by: Matthew Heon <[email protected]>
mheon added a commit to mheon/libpod that referenced this issue Jul 6, 2020
I didn't believe that this was actually legal, but it looks like
it is. And, unlike our previous understanding (host port being
empty means just use container port), empty host port actually
carries the same meaning as `--expose` + `--publish-all` (that
is, assign a random host port to the given container port). This
requires a significant rework of our port handling code to handle
this new case. I don't foresee this being commonly used, so I
optimized having a fixed port number as fast path, which this
random assignment code running after the main port handling code
only if necessary.

Fixes containers#6806

Signed-off-by: Matthew Heon <[email protected]>
@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 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 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

Successfully merging a pull request may close this issue.

4 participants