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 172.17.0.0 by default [source]. It reserves 65536 IP addresses for containers.
In my case, centOS box was in range 172.29., and docker took 172.29.1.0 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:
- run route -n
- check your box eth0 destination
- edit docker systemctl start file:
4. put docker containers in different ip range
Here is example how to set docker ip range from 172.29.1.0 – 172.29.1.255 [cidr calculator]:
ExecStart=/usr/bin/dockerd -bip 172.29.1.1/24
5. Now is save to start docker daemon:
# systemctl daemon-reload # systemctl start docker #systemctl status docker