How to change docker ip address on centos 7?

I installed docker on centos 7. Belows are the output of ifconfig command

ifconfig

docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:ea:cd:a1:19 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.149.5 netmask 255.255.255.0 broadcast 192.168.149.255
inet6 fe80::c494:6514:b641:e046 prefixlen 64 scopeid 0x20
ether 00:0c:29:57:00:09 txqueuelen 1000 (Ethernet)
RX packets 42800 bytes 26241065 (25.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 31687 bytes 4228571 (4.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 302 bytes 29477 (28.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 302 bytes 29477 (28.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:ce:2f:27 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I tried to change ip address of docker0 172.17.0.1 to 192.168.149.5, the ip address of ens33. I searched many ref site, but I can’t make it. Pls, inform me how to set the ip address of docker0 on CentOS 7. Thanks in advaned!

Hi,

You can set the network characteristics of the docker0 bridge using the guidance provided on this documentation page: https://docs.docker.com/engine/userguide/networking/default_network/custom-docker0/. Typically, on dockerd start, you’d configure the bridge IP and possibly the default gateway using the –bip and –default-gateway parameters. These could also be specified in the daemon.json file on the node.

1 Like