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
Section titled “Preparation - Update the package list”sudo apt updatesudo dnf updateInstall docker
Section titled “Install docker”sudo apt -y install docker.io docker-composesudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.reposudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-pluginEnable the service to start on boot
Section titled “Enable the service to start on boot”sudo systemctl enable dockersudo systemctl enable dockerStart the service
Section titled “Start the service”sudo systemctl start dockersudo systemctl start dockerCheck docker status
Section titled “Check docker status”sudo systemctl status dockersudo systemctl status dockerSetting up Docker’s networks
Section titled “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 dockerTest the public IP from docker
Section titled “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
Section titled “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: trueand execute this. It should generates an /80 network. Docker compose creates a default network for each docker compose file.
docker compose run --rm test