Modify the default network segment docker

A. Modify common docker run to start the container network segments
 
1. Modify the default segment
$ sudo service docker stop
$ sudo ip link set dev docker0 down
$ sudo brctl delbr docker0
 
2. Modify /etc/docker/daemon.json
vim /etc/docker/daemon.json
{
"bip": "192.168.0.1/24"
}
 
3. Restart docker
$ sudo service docker start
 
4. Check and New Container
docker run -it mysql /bin/bash
docker ps -a
docker inspect 
 
iptables -t nat -L -n to view the routing information
 
 
 
II. Modified using the docker-compose initiated container
 
Add in the /etc/docker/daemon.json
{
  "debug" : true,
  "default-address-pools" : [
    {
      "base" : "12.11.0.0/16",
      "size" : 24
    }
  ]
}
systemctl restart docker
 
 

Guess you like

Origin www.cnblogs.com/regit/p/11551144.html