Enable the service in the container to support IPv6
In fact, there is no need to allocate an IPv6 address. As long as the corresponding port is mapped, Docker will map the external IPv6 address port to the container's IPv4 port. So, just access the corresponding IPv6 port of the host.
Assign IPv6 address segment for Docker network
First, if you want to enable Docker's IPv6 support, you must ensure that your machine has an address segment of at least /80.
Edit the /etc/docker/daemon.json file and add the following content:
{ "ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64" }
Among them, 2001:db8:1::/64 is the IPv6 address segment.
Use the following command to restart Docker.
systemctl restart docker
View the assigned IPv6 address (taking Debian/Ubuntu as an example)
Use the following command to view the IPv6 address segment assigned to the Docker network.
ifconfig
If you are prompted that the command cannot be found, please use the following command to install the network tool.
apt-get install net-tools
For more related tutorials, please pay attention to thedocker tutorialcolumn on the PHP Chinese website.
The above is the detailed content of How docker selects the ipv6 address segment. For more information, please follow other related articles on the PHP Chinese website!