How to change docker default route on Centos7

Reading Time: 2 minutes


In this post I will explain how to resolve following issue. You are connected via ssh to your centOS box. You successfully installed docker on that box and you started docker daemon using systemctl. Bang!, you are disconnected from your centOS box.

This happened to me. I had successfully installed docker on several boxes without a problem. Reality check, I just scratched the surface of my docker knowledge.

Reality check. This centos box was different than previous ones. I found out that it is in different network. Luckily, there was another box in same network that I can connect to. I ssh to that box and then from that box to the original centOS box. I  am in!

I was able to log in because they were in same network subnet. My laptop was in different range. What to do in order not to be bitten by this issue?

Before you start docker daemon with systemctl, run following cmd:

[ ~]$ route -n

route shows/manipulates routing table. Routing table describe where IP packets should go. Picture above shows ok situation. docker and linux box have different destination for packets.

In above example, docker took by default [source]. It reserves 65536 IP addresses for containers.

In my case, centOS box was in range 172.29., and docker took so from outside, docker took all the traffic, and my laptop was automatically disconnected.

How to change docker cidr range.

Before you start your docker daemon:

  1. run route -n
  2. check your box eth0 destination
  3. edit docker systemctl start file:
vi /usr/lib/systemd/system/docker.service

4. put docker containers in different ip range

Here is example how to set docker ip range from – [cidr calculator]:

ExecStart=/usr/bin/dockerd -bip

5. Now is save to start docker daemon:

# systemctl daemon-reload
# systemctl start docker
#systemctl status docker
Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Karlo Smid

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.