moby: Creating new service on swarm doesn't publish ports on Centos7
Output of docker version
:
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built:
OS/Arch: linux/amd64
Server:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built:
OS/Arch: linux/amd64
Output of docker info
:
Containers: 5
Running: 5
Paused: 0
Stopped: 0
Images: 6
Server Version: 1.12.1
Storage Driver: overlay2
Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge null overlay host
Swarm: active
NodeID: 4aw23p0m4s1hazwr3jw3h5lr1
Is Manager: true
ClusterID: dowu6j9g030etwhzxd1rzv5b7
Managers: 4
Nodes: 4
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Node Address: 172.16.130.111
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.7.0-1.el7.elrepo.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 32
Total Memory: 62.81 GiB
Name: www5.strippeddomain.com
ID: SSGC:WWQK:QTW2:T3OC:GAQW:RCZ7:YXAY:I5HY:XDWK:XIOS:BZWE:RTG6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
Additional environment details (AWS, VirtualBox, physical, etc.): physical machines with dual network cards. one for external, and one for internal (cross-server communication) networks
Steps to reproduce the issue: these steps are taken directly from Docker Online webinar 42
- Clean install CentOS7 or any version up to current CentOS Linux release 7.2.1511 (Core)
- install docker engine 1.12.*
- docker network create -d overlay collabnet
- docker service create --name wordpressdb1 --network collabnet -e MYSQL_ROOT_PASSWORD=mysql123 -e MYSQL_DATABASE=wordpress --replicas 2 mysql:latest
- docker service create -e WORDPRESS_DB_HOST=wordpressdb1 -e WORDPRESS_DB_PASSWORD=mysql123 --network collabnet --replicas 3 --name wordpressapp --publish 81:80/tcp wordpress:latest
Describe the results you received: Containers for all services with all replicas get spun up correctly, but port 81 does not become accessible
Describe the results you expected: Expected to be able to access port :81 on any of the nodes within the swarm cluster to be able to access wordpress interface, but none of the nodes had this port exposed.
Additional information you deem important (e.g. issue happens only occasionally): I suspect some of the things, not sure if any of them make sense:
- it looks like ipv6 is enabled, and possibly somehow interfering with ipv4 port assignment
- it’s possible that iptables on centos is the culprit
- i basically cannot start any of the containers that would have port published, none of them will publish the port
- while docker service won’t publish ports, regular docker run continues to publish ports for newly spun up services correctly
- according to reply via email - @mgoelzer confirms that this is a bug:
If I’m understanding correct, a service started like
docker service create -p 12345:12345 whatever-image /some/command/that/listens/on/12345
does not expose :12345 on all 8 of your nodes, right? Yes, that is definitely a bug. Can you open an issue about it on docker/docker and @-mention me? (@mgoelzer)
Possibly the issue has to do with iptables because of this:
systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2016-09-01 01:36:25 UTC; 5h 34min ago
Main PID: 18703 (firewalld)
Memory: 32.7M
CGroup: /system.slice/firewalld.service
└─18703 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -o docker0 -j DOCKER' failed: iptables: No chain/target/match by that name.
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -j DOCKER-ISOLATION' failed: iptables: No chain/target/match by that name.
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t nat -C POSTROUTING -s 172.19.0.0/16 ! -o docker_gwbridge -j MASQUERADE' failed: iptables: No chain/target/match by that name.
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t nat -C DOCKER -i docker_gwbridge -j RETURN' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -D FORWARD -i docker_gwbridge -o docker_gwbridge -j ACCEPT' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -i docker_gwbridge -o docker_gwbridge -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -i docker_gwbridge ! -o docker_gwbridge -j ACCEPT' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -o docker_gwbridge -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT' failed: iptables: Bad rule (does a matching rule exist in that chain?).
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -t filter -C FORWARD -o docker_gwbridge -j DOCKER' failed: iptables: No chain/target/match by that name.
Sep 01 01:36:26 www5.domain123.com firewalld[18703]: 2016-09-01 01:36:26 ERROR: COMMAND_FAILED: '/sbin/iptables -w2 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 3
- Comments: 56 (5 by maintainers)
yes, confirmed. with firewalld disabled everything seems to work ok
Comment from @outofcoffee was spot on. it didnt’ do the trick for me but it got me looking in the direction of firewalld zones and what i found was the following:
now things seem to work, but i’m afraid to switch production to start using docker services since firewalld is not something that i feel comfortable with debugging.
I guess the issue is somehow related to the zones, would be great if docker could sample all needed zone rulesets, and at this point I’m not really clear on how it would need to be setup if the server had only 1 network interface in it … super confused, off to read firewalld manuals
We are continuing to see this issue with 1.12.2-rc1 on Debian jessie with a 3.18.21 kernel.
A broken service will have these errors logged:
Only a single entry will be in DOCKER-INGRESS chain (i.e. no DNAT entry)
A curl to the local service will fail: