I have ipv6 enabled on docker host but there is one particular container where ipv6 is causing issues. Is there a way to launch a container without ipv6 support, either through command line argument or dockerfile directive?
Disable ip v6 in docker container
111.2k Views Asked by Sergei Rodionov At
7
There are 7 best solutions below
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
1

To disable ipv6, run docker container with:
-e "extra_params=--o:net.proto=IPv4"
Tested on Ubuntu 20.04, collabora office container.
UPDATE: But this did not worked runing pgadmin container, so added extra line:
-e "PGADMIN_LISTEN_ADDRESS=0.0.0.0" \
3

If you are looking to disable IPv6 from within a Linux Docker image, this seems to work even when the file system is read-only.
sysctl net.ipv6.conf.all.disable_ipv6=1
sysctl net.ipv6.conf.default.disable_ipv6=1
These commands are privileged; run with sudo
if you are not root
.
Unfortunately there isn't:
--ipv6
is a daemon-wide flag that cannot be overridden on a per-container basis.