Enable IPv6 in Docker container and compose

2 min read

Enabling IPv6 in Docker Settings.

What’s Docker

Docker stands as a groundbreaking containerization platform that has dramatically streamlined the lifecycle of developing, deploying, and managing applications. By encapsulating applications in lightweight, transportable containers, Docker ensures consistency and efficiency, regardless of the environment it operates in. This universality makes Docker an indispensable tool for developers aiming to build and scale applications swiftly and reliably across various computing environments, from personal computers to cloud-based servers. Its ability to isolate applications in containers also significantly boosts security and simplifies dependency management, making the development process more manageable and predictable.

What’s IPv6

IPv6 represents the next generation of Internet Protocol (IP) addressing, designed to overcome the limitations of its predecessor, IPv4, primarily the issue of address exhaustion. With its vast address space, IPv6 not only provides an almost unlimited number of unique IP addresses but also introduces several improvements in routing and network autoconfiguration, enhancing internet security and performance. Embracing IPv6 is essential for ensuring that devices and services on the internet remain accessible and secure as the global demand for IP addresses continues to grow, especially in the burgeoning age of IoT (Internet of Things) devices.

The integration of IPv6 into Docker containers and compositions signifies a pivotal advancement in the field of containerized application development and deployment. Docker’s seamless environment for container management, combined with IPv6’s expansive network capabilities, offers developers and organizations an unparalleled level of efficiency, scalability, and security. While Docker encapsulates and manages the lifecycle of applications in a consistent manner across different platforms, IPv6 ensures these applications are ready for the future of internet connectivity, with its vast address space and enhanced functionalities. Together, Docker and IPv6 pave the way for a more robust, scalable, and secure approach to modern networking and application development, ensuring that businesses and services can thrive in the ever-evolving digital landscape.

How to Enable IPv6 in Docker


  • Make sure the Docker servise up and running
  • Enable IP Forwarding
  • IPv6 Local Range IP, e.g: fd12:3456:789a:1::/64


# Enable IP Forwarding and stuff
vim /etc/sysctl.conf

# Append like these
net.ipv4.ip_forward = 1
net.ipv6.conf.eth0.proxy_ndp = 1
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1

# Apply sysctl.conf
sysctl -p

# Stop Docker service
systemctl stop docker docker.socket

Enable in daemon config

tee /etc/docker/daemon.json >/dev/null <<EOF
  "ipv6": true,
  "fixed-cidr-v6": "fd12:3456:789a:1::/64",
  "experimental": true,
  "ip6tables": true,
  "iptables": true

systemctl start docker

Create IPv6 Docker network

docker network create --subnet= --gateway= --ipv6 --subnet="fd12:3456:789a:2::/112" --driver bridge net_apps

Run Docker Container with IPv6

# Create Container
docker run -d --name apps --network net_apps nginx:alpine

# Login to Container
docker exec -it apps sh

# Test to ping via IPv6
$ ping6 -c3 blackonsole.org
PING blackonsole.org(2606:4700:3037::6815:ac2 (2606:4700:3037::6815:ac2)) 56 data bytes
64 bytes from 2606:4700:3037::6815:ac2 (2606:4700:3037::6815:ac2): icmp_seq=1 ttl=57 time=2.08 ms
64 bytes from 2606:4700:3037::6815:ac2 (2606:4700:3037::6815:ac2): icmp_seq=2 ttl=57 time=1.73 ms
64 bytes from 2606:4700:3037::6815:ac2 (2606:4700:3037::6815:ac2): icmp_seq=3 ttl=57 time=0.887 ms

--- blackonsole.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 0.887/1.566/2.078/0.500 ms

IPv6 in Docker Compose

# Create Docker compose file
vim docker-compose.yml

# Content of docker-compose
    name: apps
    image: nginx:alpine
    - net_apps

    external: true
# Run Docker Compose
# Foreground
docker compose up 

# OR

# Background
docker compose up -d


  • https://docs.docker.com/compose/gettingstarted/
  • https://docs.docker.com/engine/reference/run/#container-networking
  • https://docs.docker.com/config/daemon/ipv6/

Leave a Reply

Your email address will not be published. Required fields are marked *