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

docker_container cannot use --publish and --publish-all at the same time #8

Closed
tacyuuhon opened this issue Sep 14, 2020 · 4 comments · Fixed by #162
Closed

docker_container cannot use --publish and --publish-all at the same time #8

tacyuuhon opened this issue Sep 14, 2020 · 4 comments · Fixed by #162
Labels
docker-plain plain Docker (no swarm, no compose, no stack)

Comments

@tacyuuhon
Copy link

SUMMARY

When --publish and --publish-all are used at the same time, other ports except the specified port can be randomly allocated.

docker run -d -P -p 8080:8080 Nginx

Here, port 80 of Nginx will be randomly allocated.

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                           NAMES
f7253236b603        nginx               "/docker-entrypoint.…"   5 minutes ago       Up 5 minutes        0.0.0.0:8080->8080/tcp, 0.0.0.0:32793->80/tcp   xenodochial_ganguly

docker_container doesn't have this.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_container

ANSIBLE VERSION
nsible 2.9.13
  config file = None
  configured module search path = ['/Users/tacyuuhon/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
CONFIGURATION
ANSIBLE_NOCOWS(/Users/tacyuuhon/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/Users/tacyuuhon/ansible/ansible.cfg) = False
OS / ENVIRONMENT
OS

MacOS / Darwin w022581902977m 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64

Docker
Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:46:54 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:45:28 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
STEPS TO REPRODUCE
docker_container:
  name: "nginx"
  image: nginx
  pull: yes
  ports:
    - 8080:8080
    - all
  state: started
EXPECTED RESULTS

Except for the specified port, the remaining ports are randomly assigned by docker.

ACTUAL RESULTS
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                   NAMES
d1367ad373e0        nginx               "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:32796->80/tcp   nginx
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@felixfontein
Copy link
Collaborator

The documentation for the module says A value of all will publish all exposed container ports to random host ports, ignoring any other mappings., so the module does as documented (though not what docker CLI users might expect). So this is not a bug.

It's definitely something that would be nice if changed, though. It would be a breaking change though.

@gundalow gundalow transferred this issue from ansible-collections/community.general Oct 30, 2020
@felixfontein
Copy link
Collaborator

#60 deprecates the current behavior. From community.docker 2.0.0 on, the new behavior will either that this is no longer allowed, or that it is properly handled. Which behavior will be the case depends on whether someone will properly implement this. (I don't want to promise now that I will do that :) )

@felixfontein felixfontein added the docker-plain plain Docker (no swarm, no compose, no stack) label Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-plain plain Docker (no swarm, no compose, no stack)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants