Skip to main content

Install Docker and Enable IPv6 network

This document provides a comprehensive guide for installing Docker and enabling IPv6 networking on a cloud environment platform. It covers the installation process for systems using apt (Debian, Ubuntu) and dnf (CentOS, Rocky Linux, Alma Linux) package managers. By following these steps, you will be able to set up Docker for containerized application deployment and configure it to support IPv6 networking, ensuring compatibility and scalability for modern network environments.

Preparation - Update the package list

sudo apt update

Install docker

sudo apt -y install docker.io docker-compose

Enable the service to start on boot

sudo systemctl enable docker

Start the service

sudo systemctl start docker

Check docker status

sudo systemctl status docker

Setting up Docker’s networks

we are going to use the reserved range of IPv6.

  • 2001:0db8:0000:0001:1000::/68 as the default network range.
  • 2001:0db8:0000:0001:2000::/68 as a default address pool. New networks should use /80 ranges. A /68 range contains 4096 /80 subnets.
cat <<EOF | sudo tee /etc/docker/daemon.json >/dev/null
{
"ipv6": true,
"fixed-cidr-v6": "2001:0db8:0000:0001:1000::/68",
"experimental": true,
"ip6tables": true,
"default-address-pools":[
{"base": "172.31.0.0/16", "size": 24},
{"base": "2001:0db8:0000:0001:2000::/68", "size": 80}
],
"dns": ["2a00:1098:2c::1", "2a01:4f9:c010:3f02::1", "2a00:1098:2b::1"]
}
EOF

sudo systemctl restart docker

Test the public IP from docker

docker run --rm alpine wget -qO - https://ifconfig.me && echo ""

it should be show your public IPv6 address

Test the public IP from docker compose

Make a docker-compose.yaml

services:
test:
image: alpine
command: /bin/sh -c "wget -qO - https://ifconfig.me && echo ''"
networks:
default:
enable_ipv6: true

and execute this. It should generates an /80 network. Docker compose creates a default network for each docker compose file.

docker compose run --rm test

Reference