# Docker module choose random port if we didn't pass ports variable.

**URL:** <https://forum.ansible.com/t/docker-module-choose-random-port-if-we-didnt-pass-ports-variable/17875>\
**Category:** Ansible Project\
**Created:** [March 31, 2015, 12:56am UTC](https://forum.ansible.com/t/docker-module-choose-random-port-if-we-didnt-pass-ports-variable/17875 "2015-03-31T00:56:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khoa\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Khoa\_Nguyen](https://forum.ansible.com/u/Khoa_Nguyen)\
**Post date:** [March 31, 2015, 12:56am UTC](https://forum.ansible.com/t/docker-module-choose-random-port-if-we-didnt-pass-ports-variable/17875/1 "2015-03-31T00:56:29Z")

</div>

In 1.8.0 version, If I didn’t pass “ports” variable, Docker module will not bind any port to the Docker Host. It worked correctly.  
However, In 1.9.0.1, Docker module choose a random ports, and bind to Docker Host. I think there is something wrong. Please correct me if I wrong.  
If I remove this line ( ports: “{{ docker\_ports|default(omit) }}” ) , the docker module works correctly.

```auto
- name: Run docker container
docker:
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) }}"

```
