How to change the default docker subnet IP range
By default, Docker uses 172.17.0.0/16. This can conflict with your cloud subnet IP range. Here's how to update it.
Tip
Hyperglance 💙 Docker
As a Docker user, there's a high chance you could be utilizing Hyperglance to manage your cloud, and you'd be in good company. Our success stories come from all over the globe, including NASA, Vodafone, Cisco, and the U.S. Air Force.
Hyperglance users quickly come to rely on our powerful suite of cloud management tools, including:
- Real-time, interactive diagrams of your AWS, Azure & Kubernetes infrastructure
- Automatic inventory documentation with export options
- Powerful search capability, across your entire inventory (including metadata)
- Cloud cost optimization, security & compliance monitoring, and cloud automation & remediation
For more information, visit hyperglance.com
Note
This guide only pertains to our legacy Docker based deployments.
How To Change The Default Docker Subnet IP Range
Step 1: Connect to the VM
SSH into the Hyperglance Instance/VM.
Step 2: Set the Docker bridge IP range
You need to edit /etc/docker/daemon.json:
sudo vi /etc/docker/daemon.jsonAdd "bip": "172.26.0.1/16" to the JSON, in daemon.json.
The JSON will look like this after you have updated it:
{
"log-driver": "journald",
"log-opts": {
"tag": ""
},
"bip": "172.26.0.1/16"
}
Step 3: Restart Docker
Restart Docker:
sudo systemctl restart dockerStep 4: Check the routing table
Check the routing table:
netstat -rnYou should see the following output (note the penultimate row):
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 172.31.16.1 0.0.0.0 UG 0 0 0 eth0
169.254.169.254 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-e9768d205a82
172.26.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.31.16.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0Once you're done, the docker containers will restart, then begin to collect.