docker and the issue of the default IP subnet

Have you had trouble getting the docker set up and suddenly recognize that the default docker bridge and its wide subnet conflicting with your private network?
Here is a recipe to address this as it took me a while to find out and seriously it must not be that way. The culprit in my opinion is that 172.17.0.0/16 is too wide by default 😉
a. Get the docker service stopped:
sudo systemctl stop docker
b. Get the list of the bridges to double check
sudo brctl show
c. Bring down the docker0 bridge
sudo ip link set device docker0 down
d. Delete the docker0 bridge all together to create it from scratch
sudo brctl delbr docker0
e. Recreate it with smaller subnet-as an old patron of kvm and getting used to the 122 value in the third octet and simplifying this process to remember I’ll go with 172.17.122.0/24:
sudo brctl addbr docker0
f. final touch
sudo ip addr add 172.17.122.0/24 dev docker0
g. bring up the bridge/service and look at the service details for the new bridge value
sudo ip link set dev docker0 up
systemctl start docker && systemctl status docker -l
voila

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.