Change Docker IP address easily

Docker Moby Logo

By default, Docker uses 172.17.0.0/16 for its default docker0 interface, which can be problematic if your network or a network you want to reach is on the same subnet as Docker. I will show you how to change Docker’s network in a jiffy!

Requirements

  • Available subnet to assign to Docker
  • Permission to create or modify /etc/docker/daemon.json

Start by thinking of a good subnet that you want to assign to Docker. In this example, we will use 192.168.219.1/24 as the new subnet.

Then, create the file /etc/docker/daemon.json with your favourite editor like nano, and inside of it you’ll want to enter:

{
    "bip": "192.168.219.1/24"
}

Of course replacing it with your chosen subnet.

Save and exit the editor, and then restart Docker with:

systemctl restart docker

If that does not work for you, you might have to reboot your machine.

Note that in this example 192.168.219.1 will become the host’s docker0 IP address.

That’s all!

External Links

Leave a Reply

Your email address will not be published.

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