docker.service startup failure: Causes and solutions for Unit not found

  • 2020-06-12 11:33:11
  • OfStack

background

As the Kubernetes cluster version upgrade and Docker version upgrade have been going on for a long time recently, the test environment has been installed, restored, upgraded and degraded in a chaotic way. Finally, when launching Docker after testing the Docker version upgrade, I encountered ES7en.service: Unit not found. It's not a big problem, but it's been tormenting me for hours, so here's mark1.

Operating system: Red Hat Enterprise Linux 7

Reason 1: docker.socket

The initial problem with starting docker was caused by ES26en.socket, although it is not clear whether the problem manifested as Unit not found or systemctl start ES33en.service when systemctl start docker stopped, it is also recorded here.

Problem description

I upgraded from Docker 1.10.3 to version 1.13.1 and installed through the rpm package. 1 some Docker due to keep the custom configuration, so after the upgrade, use the original/usr/lib systemd/system/docker service covers new docker. service. However, in version 1.10.3, docker. service [UNIT] specifies that Requires= docker. socket, that is, docker. service relies on docker. socket by default, because docker. socket is needed to obtain the container information.


[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

However, in version 1.13.1, the system is no longer dependent on ES67en.socket, so docker.socket is not in the system, but I continue to use the original ES71en.service, so when I boot, there will be an error.

The solution

Delete/usr/lib/systemd/system/docker service [UNIT] contains the docker. socket, then systemctl daemon - reload, finally systemctl start docker. service, found that started successfully.

A similar situation

In a similar case, docker.socket is missing, but the new version requires ES99en.socket. There are two ways to solve this problem:

You can uninstall docker and reinstall it, and docker.socket appears. or Create a/usr lib systemd/system/docker socket file, then systemctl daemon - reload, finally systemctl start docker. service, can be started successfully.

/ usr lib systemd/system/docker socket file is as follows:


[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target

Reason 2: flanneld.service

As described in the background, I happened to have installed Kubernetes and flannel on the machine in question, and then deleted what I thought were "all" related files. It is because the flannel file was not deleted cleanly that the problem with ES135en.service: Unit not found occurs.

Problem description

After determining that it was not caused by the problem of ES144en.socket, my first reaction was to delete flannel, as I understood that ES147en.service and ES149en.service were directly associated with the starting order:


[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
After=network-online.target
Wants=network-online.target
After=etcd.service
Before=docker.service

Is really bothering me for a long time, / usr/lib/systemd/system/flanneld service I already deleted, also systemctl daemon - reload, whether there is leakage which files deleted.

On examination/etc/systemd/system/flanneld service still exists, and exist/etc/systemd/system/docker service. requires directory in the directory contains the soft connection flanneld. service, the soft links pointing to the real flanneld. service, so as to realize the startup sequence of the two services.

Common commands used to locate such problems are:

systemctl ES184en-ES185en-ES186en Lists all available Unit systemctl ES189en-ES190en lists all Unit running systemctl -failed lists all failed units systemctl mask httpd.service disabled services systemctl unmask httpd.service systemctl kill httpd Kill Service systemd-analyze ES204en-ES205en: Analyze the key chain at startup systemd-analyze blame analyzes the time spent by each process at startup

The solution

systemctl unmask flanneld.service disables the flanneld service and then deletes it
/ etc/systemd/system/docker service. requires/flanneld service, use systemctl daemon - reload reload service configuration file, the final systemctl start docker. service, found docker started successfully.


Related articles: