By default, when we install Docker on our computer, Docker will create a bridge interface namely docker0. Docker uses 172.17.0.1 IP address and 172.17.0.0/16 subnet for docker0.

 Change Docker's IP Address and Subnet


Can we change docker0’s IP address and subnet? Yes, We can change it!

In this short tutorial, I show you step by step instructions on how to change docker0’s IP address and subnet.

For your information, I use Docker 1.13.0 on Ubuntu 14.04.4 LTS.

Step 1

Check whether daemon.json file is in /etc/docker/. If you can not find it, create the file by this command:

sudo touch /etc/docker/daemon.json

Step 2

Edit daemon.json file.

sudo nano /etc/docker/daemon.json
1
2
3
{
    "bip": "10.10.254.1/24"
}

The code above is in JSON format. What does the code mean? Docker will use 10.10.254.1 IP address and 10.10.254.0/24 subnet for docker0 interface.

Don’t forget to save.

Step 3

Restart the Docker daemon.

sudo service docker restart

Check docker0’s IP address and subnet.

ifconfig docker0
 Change Docker's IP Address and Subnet