Docker Community Forums

Share and learn in the Docker community.

How to disable IPv6 in Docker (CentOS 7)?

I’m running docker on CentOS Linux release 7.7.1908 (Core), IPv6 is disabled in the OS, however Docker and Docker swarm is still listening on IPv6. Do you have an idea what’s happening?

host% sysctl net.ipv6.conf.all.disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 1
host% sysctl net.ipv6.conf.default.disable_ipv6
net.ipv6.conf.default.disable_ipv6 = 1
host% ip a s ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:a0:34:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.72.131/24 brd 192.168.72.255 scope global noprefixroute dynamic ens33
valid_lft 1626sec preferred_lft 1626sec
host% ip a s docker0
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:26:d6:bd:d4 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever

host% docker service create --name hello-template --env HELLO=“Docker” --config source=homepage,target=/usr/share/nginx/html/index.html --publish published=3000,target=80 nginx:alpine

Then when I do a sockstat:
ss -utln
tcp LISTEN [::]:3000