Docker & Host System IP Conflict

Docker uses the default 172.17. 0.0/16 subnet for container networking. If your host system is in this subnet block, you will experience an IP conflict when the docker service or a container is started. To avoid IP conflict, you can change the default docker subnet by modifying the /etc/docker/daemon.json file:

  • First, check if /etc/docker/daemon.json exists, if not, create it:

touch /etc/docker/daemon.json
  • Modify daemon.json file with a preferred text editor

sudo nano /etc/docker/daemon.json

Paste the following lines:

{ "default-address-pools": [ {"base":"10.10.0.0/16","size":24} ] }

  • Save the file by clicking “ctrl+x” and then clicking “y” and finally pressing the “enter".

  • Restart docker service by executing the following command:

sudo service docker restart
  • Check the IP address of the docker0 interface:

ifconfig docker0
  • The output should look like this:

docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 10.10.0.1 netmask 255.255.0.0 broadcast 10.10.255.255 ether AA:BB:CC:DD:EE:FF 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

Last updated