修改docker默认IP

DevOps Docker评论3,831字数 1976阅读6分35秒阅读模式

默认安装的docker一般是以网桥bridge模式提供一个网络,默认的地址是172.17.0.1/16

[root@jenkins jenkins]# ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:af:fd:4a brd ff:ff:ff:ff:ff:ff
inet 192.168.90.9/24 brd 192.168.90.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::1b77:75f:77c7:f882/64 scope link noprefixroute 
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 02:42:38:96:ae:e5 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever

如果发现这个docker0的网段跟已有网段冲突的话,只能修改

  • 停止正在运行的docker服务
[root@jenkins ~]# systemctl stop docker
  • 修改docker配置文件,添加新的网段信息
[root@jenkins ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"],"bip": "172.17.12.1/16"
}

修改docker默认IP

  • 启动Docker,再次查看网络,发现修改成功
[root@jenkins ~]# systemctl start docker
  • 查看IP
[root@jenkins ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:af:fd:4a brd ff:ff:ff:ff:ff:ff
inet 192.168.90.9/24 brd 192.168.90.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::1b77:75f:77c7:f882/64 scope link noprefixroute 
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 02:42:38:96:ae:e5 brd ff:ff:ff:ff:ff:ff
inet 172.17.12.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever

继续阅读
DevOps
  • 本文由 发表于 2023年2月22日 14:17:10
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
docker-compose Docker

docker-compose

curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname ...
安装Docker Docker

安装Docker

添加Docker CE的软件源信息 yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-man...
评论  0  访客  0

发表评论