一般docker 默认的网络端是172.17.0.1的网段,在生产环境中可能会有办公端IP端冲突
停止所有容器
优先推荐down掉所有
docker rm $(docker ps -a -q)
删除docker 网络
docker network list
#my-network为要删除的网络名称
docker network rm my-network
停止docker
systemctl stop docker
对daemon.json添加如下内容
修改/etc/docker/daemon.json(daemon.json没有就新建)文件,加入以下代码
vi /etc/docker/daemon.json
{
"default-address-pools":[
{"base":"172.21.0.0/16","size":24},
{"base":"172.22.0.0/16","size":24},
{"base":"172.23.0.0/16","size":24},
{"base":"172.25.0.0/16","size":24},
{"base":"172.26.0.0/16","size":24},
{"base":"172.27.0.0/16","size":24},
{"base":"172.29.0.0/16","size":24},
{"base":"172.30.0.0/16","size":24}
],
"bip":"172.20.0.1/24"
}
#配置方法2
重新加载配置,并启动docker
systemctl daemon-reload
Systemctl start docker
#如下为示例,修改默认网段,日志数量,存储位置
vi /etc/docker/daemon.json
{
"bip": "192.168.10.1/24",
"log-level": "warn",
"log-driver": "json-file",
"log-opts": {
"max-size": "500m",
"max-file": "5"
},
"data-root":"/data/docker_dir"
}
systemctl daemon-reload
systemctl restart docker