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?

  • How to write an Ansible playbook with Docker-compose
  • Using Ansible docker_service module to deploy service to swarm
  • Issues getting Ansible to work with Boot2Docker
  • Ansible docker_container command failing with no output
  • SaltStack Caches installing package files and reproduce installation later
  • docker extra_host parameter expects a dictionary value for hostname, how can I use a variable?
  • - 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) }}"

  • Requiring apt::source as a dependency gives a syntax error
  • Docker-machine create with generic driver, Certificates not working but SSH does
  • How to access a directory in hosts machine from inside a docker container?
  • Why does pecl install a different version for xdebug on another host when using same Dockerfile?
  • ERROR - Docker-compose/docker Windows
  • Docker container with build output and no source
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.