Disable ip v6 in docker container

I have ipv6 enabled on the docker host, but there is one specific container in which ipv6 is causing problems. Is there a way to start the container without ipv6 support, either using the command line argument or the dockerfile directive?

+5
source share
5 answers

Unfortunately, no: --ipv6- this is a flag of the entire area of ​​the daemon that cannot be redefined for each container.

+2
source

Two options:

  • Launch docker with --dns-opt='options single-request'. See docs
  • Run with --sysctl net.ipv6.conf.all.disable_ipv6=1. See discussion here
+7
source

. , , ip:

docker run --name YourDockerContainer -p 192.168.99.100:80:80

ip: 192.168.99.100.

+4

docker --sysctl net.ipv6.conf.all.disable_ipv6=1 , , .

--sysctl net.ipv6.conf.all.disable_ipv6=0

0

Worked for me:

docker run -d -i -t  --name django_1.0 --sysctl 
net.ipv6.conf.all.disable_ipv6=1 -p 192.168.20.148:8000:8000/tcp -p 
192.168.20.148:8000:8000/udp -p 192.168.20.148:3000:3000/tcp -p 
192.168.20.148:3000:3000/udp IMAGE_NAME

root:~# netstat -tlp | grep -i docker

tcp  0  0 ip-192-168-20-148.:8000 *:*    LISTEN      4598/docker-proxy

tcp  0  0 ip-192-168-20-148.:3000 *:*    LISTEN      4642/docker-proxy
0
source

All Articles