Issue 1:
Re-opening #2526 as it was closed as duplicate. It is still reproducible in 1.9.01

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

docker_container module

ANSIBLE VERSION

ansible 2.2.1.0
config file = /Users/alebedev/projects/ansible/ansible.cfg
configured module search path = Default w/o overrides

OS / ENVIRONMENT

N/A

SUMMARY

port_published: 'all' is not working in docker_container module and return the following error

TASK [pool : Starting a container] *************************
fatal: [pool]: FAILED! => {
"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))"}")

STEPS TO REPRODUCE

- name: Starting a container
docker_container:
name: pool
image: pool
privileged: true
network_mode: bridge
exposed_ports: "{{ ports }}"
published_ports: 'all'
detach: true
volumes:
restart_policy: on-failure
interactive: true
state: started

EXPECTED RESULTS

Container successfully up and running with all the exposed port - published

ACTUAL RESULTS

fatal: [pool]: FAILED! => {
"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))"}")