Disable ip v6 in docker container

Two options:

  1. Run docker with --dns-opt='options single-request'. See docs
  2. Run with --sysctl net.ipv6.conf.all.disable_ipv6=1. See discussion here

Its kind of tricky. I just had the same issue what I did was to run the container with the ip:

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

This will start the container on this ip: 192.168.99.100.


Unfortunately there isn't: --ipv6 is a daemon-wide flag that cannot be overridden on a per-container basis.


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.

Tags:

Docker

Ipv6