Change default docker0 bridge IP address

I recently had a client with a similar issue where 172.17.1.1 was actually the subnet of his company’s wifi. I found a workaround for him but it’s also quite hacky:

ip addr add dev docker0 172.18.0.1/16 – This adds a new IP range. You can use whatever range you want.
ip addr del dev docker0 172.17.0.1/16 – This deletes the old range

Here’s the problem, Docker is hard coded to look for 172.17.0.1. Changing this will require a rewrite of Docker’s code. If it can’t find 172.17.0.1/16, then any container using the default network will lose connectivity. Also, Docker recreates bridge0 every time it is loaded, so you will need to change the range again every time you reboot or restart the docker service.

Here’s the workaround to get your containers working after you change the bridge IP.

docker network create tempnet – This creates a new temporary network. You can name it what you want.
New containers that would normally use the default network will need to include “–net tempnet” in order.

Example:
docker run -it --net tempnet opensuse /bin/bash