<p dir="auto">Re-opening <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="12592940" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/2526" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/2526/hovercard" href="https://github.com/ansible/ansible/issues/2526">#2526</a> as it was  closed as duplicate. It is still reproducible in 1.9.01</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">docker_container module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file = /Users/alebedev/projects/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /Users/alebedev/projects/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">port_published: 'all' is not working in docker_container module and return the following error</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [pool : Starting a container] *************************
fatal: [pool]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;failed&quot;: true
}

MSG:

Error starting container 8ccea4c73191b608575d78c2a6ecb03024ae4e5f5430ac6f292b5b6fe2106f70: 500 Server Error: Internal Server Error (&quot;{&quot;message&quot;:&quot;driver failed programming external connectivity on endpoint pool (485e1d86db8c7d7d1bcc3ecd645a8a899801ec44cb3bc9c3b45d3b9c8734172d):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 32789 -j DNAT --to-destination 172.17.0.2:0 ! -i docker0: iptables v1.4.21: Port `0' not valid\n\nTry `iptables -h' or 'iptables --help' for more information.\n (exit status 2))&quot;}&quot;)"><pre class="notranslate"><code class="notranslate">TASK [pool : Starting a container] *************************
fatal: [pool]: FAILED! =&gt; {
    "changed": false,
    "failed": true
}

MSG:

Error starting container 8ccea4c73191b608575d78c2a6ecb03024ae4e5f5430ac6f292b5b6fe2106f70: 500 Server Error: Internal Server Error ("{"message":"driver failed programming external connectivity on endpoint pool (485e1d86db8c7d7d1bcc3ecd645a8a899801ec44cb3bc9c3b45d3b9c8734172d):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 32789 -j DNAT --to-destination 172.17.0.2:0 ! -i docker0: iptables v1.4.21: Port `0' not valid\n\nTry `iptables -h' or 'iptables --help' for more information.\n (exit status 2))"}")
</code></pre></div>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
- name: Starting a container
  docker_container:
    name: pool
    image: pool
    privileged: true
    network_mode: bridge
    exposed_ports: &quot;{{ ports }}&quot;
    published_ports: 'all'
    detach: true
    volumes:
    restart_policy: on-failure
    interactive: true
    state: started"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Starting a container</span>
  <span class="pl-ent">docker_container</span>:
    <span class="pl-ent">name</span>: <span class="pl-s">pool</span>
    <span class="pl-ent">image</span>: <span class="pl-s">pool</span>
    <span class="pl-ent">privileged</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">network_mode</span>: <span class="pl-s">bridge</span>
    <span class="pl-ent">exposed_ports</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ ports }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">published_ports</span>: <span class="pl-s"><span class="pl-pds">'</span>all<span class="pl-pds">'</span></span>
    <span class="pl-ent">detach</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">volumes</span>:
    <span class="pl-ent">restart_policy</span>: <span class="pl-s">on-failure</span>
    <span class="pl-ent">interactive</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">state</span>: <span class="pl-s">started</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Container successfully up and running with all the exposed port - published</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [pool]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;failed&quot;: true,
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;api_version&quot;: null,
            &quot;blkio_weight&quot;: null,
            &quot;cacert_path&quot;: null,
            &quot;capabilities&quot;: null,
            &quot;cert_path&quot;: null,
            &quot;cleanup&quot;: false,
            &quot;command&quot;: null,
            &quot;cpu_period&quot;: null,
            &quot;cpu_quota&quot;: null,
            &quot;cpu_shares&quot;: null,
            &quot;cpuset_cpus&quot;: null,
            &quot;cpuset_mems&quot;: null,
            &quot;debug&quot;: false,
            &quot;detach&quot;: true,
            &quot;devices&quot;: null,
            &quot;dns_opts&quot;: null,
            &quot;dns_search_domains&quot;: null,
            &quot;dns_servers&quot;: null,
            &quot;docker_host&quot;: null,
            &quot;entrypoint&quot;: null,
            &quot;env&quot;: null,
            &quot;env_file&quot;: null,
            &quot;etc_hosts&quot;: null,
            &quot;exposed_ports&quot;: [
                &quot;8080:8080&quot;,
                &quot;5000-5040:5000-5040&quot;,
                &quot;7100-7140:7100-7140&quot;,
                &quot;7700-7740:7700-7740&quot;
            ],
            &quot;filter_logger&quot;: false,
            &quot;force_kill&quot;: false,
            &quot;groups&quot;: null,
            &quot;hostname&quot;: null,
            &quot;ignore_image&quot;: false,
            &quot;image&quot;: &quot;pool&quot;,
            &quot;interactive&quot;: true,
            &quot;ipc_mode&quot;: null,
            &quot;keep_volumes&quot;: true,
            &quot;kernel_memory&quot;: null,
            &quot;key_path&quot;: null,
            &quot;kill_signal&quot;: null,
            &quot;labels&quot;: null,
            &quot;links&quot;: null,
            &quot;log_driver&quot;: null,
            &quot;log_options&quot;: null,
            &quot;mac_address&quot;: null,
            &quot;memory&quot;: &quot;0&quot;,
            &quot;memory_reservation&quot;: null,
            &quot;memory_swap&quot;: null,
            &quot;memory_swappiness&quot;: null,
            &quot;name&quot;: &quot;pool&quot;,
            &quot;network_mode&quot;: &quot;bridge&quot;,
            &quot;networks&quot;: null,
            &quot;oom_killer&quot;: null,
            &quot;oom_score_adj&quot;: null,
            &quot;paused&quot;: false,
            &quot;pid_mode&quot;: null,
            &quot;privileged&quot;: true,
            &quot;published_ports&quot;: [
                &quot;all&quot;
            ],
            &quot;pull&quot;: false,
            &quot;purge_networks&quot;: false,
            &quot;read_only&quot;: false,
            &quot;recreate&quot;: false,
            &quot;restart&quot;: false,
            &quot;restart_policy&quot;: &quot;on-failure&quot;,
            &quot;restart_retries&quot;: null,
            &quot;security_opts&quot;: null,
            &quot;shm_size&quot;: null,
            &quot;ssl_version&quot;: null,
            &quot;state&quot;: &quot;started&quot;,
            &quot;stop_signal&quot;: null,
            &quot;stop_timeout&quot;: null,
            &quot;timeout&quot;: null,
            &quot;tls&quot;: null,
            &quot;tls_hostname&quot;: null,
            &quot;tls_verify&quot;: null,
            &quot;trust_image_content&quot;: false,
            &quot;tty&quot;: false,
            &quot;ulimits&quot;: null,
            &quot;user&quot;: null,
            &quot;uts&quot;: null,
            &quot;volume_driver&quot;: null
        },
        &quot;module_name&quot;: &quot;docker_container&quot;
    }
}

MSG:

Error starting container 8ccea4c73191b608575d78c2a6ecb03024ae4e5f5430ac6f292b5b6fe2106f70: 500 Server Error: Internal Server Error (&quot;{&quot;message&quot;:&quot;driver failed programming external connectivity on endpoint pool (ed49422f76e5f1421e07c790586776b8ea14b4db7191aa04953719a2a95e52e7):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 32800 -j DNAT --to-destination 172.17.0.2:0 ! -i docker0: iptables v1.4.21: Port `0' not valid\n\nTry `iptables -h' or 'iptables --help' for more information.\n (exit status 2))&quot;}&quot;)"><pre class="notranslate"><code class="notranslate">fatal: [pool]: FAILED! =&gt; {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "api_version": null,
            "blkio_weight": null,
            "cacert_path": null,
            "capabilities": null,
            "cert_path": null,
            "cleanup": false,
            "command": null,
            "cpu_period": null,
            "cpu_quota": null,
            "cpu_shares": null,
            "cpuset_cpus": null,
            "cpuset_mems": null,
            "debug": false,
            "detach": true,
            "devices": null,
            "dns_opts": null,
            "dns_search_domains": null,
            "dns_servers": null,
            "docker_host": null,
            "entrypoint": null,
            "env": null,
            "env_file": null,
            "etc_hosts": null,
            "exposed_ports": [
                "8080:8080",
                "5000-5040:5000-5040",
                "7100-7140:7100-7140",
                "7700-7740:7700-7740"
            ],
            "filter_logger": false,
            "force_kill": false,
            "groups": null,
            "hostname": null,
            "ignore_image": false,
            "image": "pool",
            "interactive": true,
            "ipc_mode": null,
            "keep_volumes": true,
            "kernel_memory": null,
            "key_path": null,
            "kill_signal": null,
            "labels": null,
            "links": null,
            "log_driver": null,
            "log_options": null,
            "mac_address": null,
            "memory": "0",
            "memory_reservation": null,
            "memory_swap": null,
            "memory_swappiness": null,
            "name": "pool",
            "network_mode": "bridge",
            "networks": null,
            "oom_killer": null,
            "oom_score_adj": null,
            "paused": false,
            "pid_mode": null,
            "privileged": true,
            "published_ports": [
                "all"
            ],
            "pull": false,
            "purge_networks": false,
            "read_only": false,
            "recreate": false,
            "restart": false,
            "restart_policy": "on-failure",
            "restart_retries": null,
            "security_opts": null,
            "shm_size": null,
            "ssl_version": null,
            "state": "started",
            "stop_signal": null,
            "stop_timeout": null,
            "timeout": null,
            "tls": null,
            "tls_hostname": null,
            "tls_verify": null,
            "trust_image_content": false,
            "tty": false,
            "ulimits": null,
            "user": null,
            "uts": null,
            "volume_driver": null
        },
        "module_name": "docker_container"
    }
}

MSG:

Error starting container 8ccea4c73191b608575d78c2a6ecb03024ae4e5f5430ac6f292b5b6fe2106f70: 500 Server Error: Internal Server Error ("{"message":"driver failed programming external connectivity on endpoint pool (ed49422f76e5f1421e07c790586776b8ea14b4db7191aa04953719a2a95e52e7):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 32800 -j DNAT --to-destination 172.17.0.2:0 ! -i docker0: iptables v1.4.21: Port `0' not valid\n\nTry `iptables -h' or 'iptables --help' for more information.\n (exit status 2))"}")
</code></pre></div>