How to solve Network IP conflict when running Docker?

Sometimes docker container networks created will conflict with the network configuration you have.

To fix it, I’m using the following configuration on my local machine:

# /etc/docker/daemon.json
{
    "bip": "192.168.199.1/28",
    "dns": ["8.8.8.8", "8.8.4.4"]
}

This configuration will limit the IP addresses of the docker containers to 192.168.199.1 CIDR block. In addition you may want to troubleshoot. This may help you identify any potential conflict between your network / DNS server addresses and your existing networks / bridges created by docker.

# list the interfaces can help you identify what networks do you have
ifconfig

# will display DNS servers used and other information of the used network interface 
nmcli device show [interface name]

# investigate the routing table to make sure that the destination interfaces are correct
# and none of the DNS servers used will get blocked by a network / bridge
route -n

# display the bridge networks using bridge administrator tool
sudo apt-get install bridge-utils
brctl show

# delete any docker networks which may be conflicting with the current settings
docker network prune

I have done these steps several times and found it helpful to solve my issues.

Hope this helps !

Publish Date: 2019-07-17