Detailed explanation of an investigation of docker. service startup error report
- 2021-09-12 02:41:06
- OfStack
Execute the following command to report an error
systemctl restart docker
View error messages
systemctl status docker -l
The error message is as follows:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
Off- kolla.conf
Active: failed (Result: exit-code) since 3 2018-08-01 16:32:27 CST; 52min ago
Docs: https://docs.docker.com
Process: 3833722 ExecStart=/usr/bin/docker daemon --insecure-registry 172.16.59.153 (code=exited, status=1/FAILURE)
Main PID: 3833722 (code=exited, status=1/FAILURE)
Memory: 8.0K
CGroup: /system.slice/docker.service
8 Month 01 16:32:26 czwei004 systemd[1]: Starting Docker Application Container Engine...
8 Month 01 16:32:26 czwei004 docker[3833722]: time="2018-08-01T16:32:26.527063936+08:00" level=info msg="libcontainerd: new containerd process, pid: 3833733"
8 Month 01 16:32:27 czwei004 docker[3833722]: time="2018-08-01T16:32:27.532317497+08:00" level=warning msg="devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section."
8 Month 01 16:32:27 czwei004 docker[3833722]: time="2018-08-01T16:32:27.560010414+08:00" level=warning msg="devmapper: Base device already exists and has filesystem xfs on it. User specified filesystem will be ignored."
8 Month 01 16:32:27 czwei004 docker[3833722]: time="2018-08-01T16:32:27.577758251+08:00" level=fatal msg="Error starting daemon: error initializing graphdriver: \"/var/lib/docker\" contains several valid graphdrivers: devicemapper, overlay2; Please cleanup or explicitly choose storage driver (-s <DRIVER>)"
8 Month 01 16:32:27 czwei004 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
8 Month 01 16:32:27 czwei004 systemd[1]: Failed to start Docker Application Container Engine.
8 Month 01 16:32:27 czwei004 systemd[1]: Unit docker.service entered failed state.
8 Month 01 16:32:27 czwei004 systemd[1]: docker.service failed.
Notice that in the above error message,
msg="Error starting daemon: error initializing graphdriver: \"/var/lib/docker\" contains several valid graphdrivers: devicemapper, overlay2; Please cleanup or explicitly choose storage driver (-s < DRIVER > )"
Go to the docker directory, there are devicemapper directory and overlay2 directory
The reason is that I installed a higher version of docker-engine before, and the default storage driver is overlay2. When I uninstalled, the folder of overlay2 remained in the directory of docker. Later, I installed a lower version of docker, and the default is devicemapper, so I have multiple storage drivers
After restarting the machine, delete the directory of overlay2 and start it.
Additional knowledge: CentOS7 modifies the default storage location of Docker image
Stop docker service
# systemctl stop docker
Modify the docker service startup file
# vim /etc/sysconfig/docker
OPTIONS='--selinux-enabled --log-driver=journald --graph=/docker --signature-verification=false --insecure-registry 192.168.1.1'
#--insecure-registry 192.168.1.1 This is a warehouse address that can be ignored
# /docker This directory is what I use instead of the default /var/lib/docker The directory, remember after the directory is created " mv /var/lib/docker/* /docker/ ", put all the original
First, all files and directories in the directory are copied to the new directory.
Reload the configuration and start
# systemctl daemon-reload
# systemctl start docker
Check docker information
# docker info