Ansible docker module picks random port by default

In Ansible 1.8.0, if I didn’t pass “ports” variable, the container would not bind any port to the Docker host. This worked correctly.

However, in Ansible, the container chooses a random port and binds it to the Docker host. Is this the new expected behavior? How to avoid automatic port binding?

  • Docker image is not visible when I run docker ps
  • How to run etcd cluster in docker using ansible?
  • /opt/ansible/ansible/bin/ansible-playbook: no such file or directory ERROR: Encountered errors while bringing up the project
  • Ansible, how to add user to group only if user exists
  • How Docker and Ansible fit together to implement Continuos Delivery/Continuous Deployment
  • Can't connect to MySQL docker container launched via ansible
  • - name: Run docker container
        image: "{{ docker_image }}"
        name: "{{ docker_name }}"
        command: "{{ docker_command|default(omit) }}"
        ports: "{{ docker_ports|default(omit) }}"
        env: "{{ docker_env|default(omit) }}"
        volumes: "{{ docker_volumes|default(omit) }}"

  • Error copying file for Docker instantiation
  • Make Jenkins run docker without sudo
  • Docker private registry with mirror
  • how do i backup a database in docker
  • Docker Swarm Raft consensus
  • How to connect PyCharm to a python interpreter located inside a Docker container?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.