Docker's docker container flannel mode multiple network segments across hosts
Problem 1: docker cannot be started
Error prompt:
[root@localhost docker.service.d] # systemctl status docker.service
● docker.service-Docker Application Container Engine
Loaded: error (Reason: Invalid argument)
Drop-In: / usr/lib/systemd/system/docker.service.d
└─ flannel.conf
Active: failed (Result: start-limit) since Fri 2020-01-17 01:18:59 PST; 4min 57s ago
Docs: https://docs.docker.com
Main PID: 9775 (code=exited, status=1/FAILURE)
Jan 17 01:18:56 localhost.localdomain systemd [1]: docker.service failed.
Jan 17 01:18:59 localhost.localdomain systemd [1]: docker.service holdoff time over, scheduling restart.
Jan 17 01:18:59 localhost.localdomain systemd [1]: Stopped Docker Application Container Engine.
Jan 17 01:18:59 localhost.localdomain systemd [1]: start request repeated too quickly for docker.service
Jan 17 01:18:59 localhost.localdomain systemd [1]: Failed to start Docker Application Container Engine.
Jan 17 01:18:59 localhost.localdomain systemd [1]: Unit docker.service entered failed state.
Jan 17 01:18:59 localhost.localdomain systemd [1]: docker.service failed.
Jan 17 01:20:37 localhost.localdomain systemd [1]: docker.service has more than one ExecStart= setting, wh...ing.
Jan 17 01:21:34 localhost.localdomain systemd [1]: docker.service has more than one ExecStart= setting, wh...ing.
Jan 17 01:23:46 localhost.localdomain systemd [1]: docker.service has more than one ExecStart= setting, wh...ing.
Hint: Some lines were ellipsized, use-l to show in full.
Resolve:
Upgrade the kernel:
[root@localhost docker.service.d] # yum update-y
After the upgrade is complete, uninstall the old version and reinstall docker-ce.
[root@localhost docker.service.d] # rpm-qa | grep docker-ce
Docker-ce-19.03.5-3.el7.x86_64
Docker-ce-cli-19.03.5-3.el7.x86_64
[root@localhost docker.service.d] # rpm-e-nodeps docker-ce-19.03.5-3.el7.x86_64
[root@localhost docker.service.d] # rpm-e-nodeps docker-ce-cli-19.03.5-3.el7.x86_64
[root@localhost docker.service.d] # yum install-y docker-ce-*
[root@localhost docker.service.d] # systemctl start docker
[root@localhost docker.service.d] # systemctl status docker
Docker starts normally!
Reflect: can you install flannel first, and then follow docker-ce? will a similar situation occur? To be tested!
Problem 2: docker and flannel start normally, but docker0 cannot get the address pool address.
Resolve:
Modify / usr/lib/systemd/system/docker.service file
[root@localhost docker.service.d] # vim / usr/lib/systemd/system/docker.service
Add the following:
Add $DOCKER_NETWORK_OPTIONS after ExecStart=/usr/bin/dockerd
Add at the end of [server]
EnvironmentFile=/run/flannel/docker
Restart docker
[root@localhost docker.service.d] # systemctl daemon-reload
[root@localhost docker.service.d] # systemctl restart docker.service
[root@localhost docker.service.d] # ifconfig
Docker0 normally acquires the flannel address pool.