Recently, I rebuild a nginx container with a Dockerfile. But it said Error response from daemon: Cannot restart container aa_php: Cannot link to a non running container: /img AS /nginx/php
. So i try systemctl restart docker.service
. it fails!
sh$ uname -a
Linux izwz94xswj2tx8086sbgnrz 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
sh$ docker version
Client:
Version: 17.10.0-ce
API version: 1.33
Go version: go1.8.3
Git commit: f4ffd25
Built: Tue Oct 17 19:04:05 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
sh$ docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
-- Unit docker.service has begun starting up.
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23.396022007+08:00" level=info msg="libcontainerd: starte
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="starting containerd" module=con
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="changing OOM score to -500" mod
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.c
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.s
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=warning msg="failed to load plugin io.con
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.s
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.m
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=warning msg="could not use snapshotter bt
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.d
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.m
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.r
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="loading plugin "io.containerd.g
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg=serving... address="/var/run/doc
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg=serving... address="/var/run/doc
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: time="2017-12-02T12:30:23+08:00" level=info msg="containerd successfully booted
Dec 02 12:30:23 VM_0_15_centos dockerd[11830]: Error starting daemon: error initializing graphdriver: /var/lib/docker contains
Dec 02 12:30:23 VM_0_15_centos systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 02 12:30:23 VM_0_15_centos systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: Unit docker.service entered failed state.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: docker.service failed.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: docker.service holdoff time over, scheduling restart.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: start request repeated too quickly for docker.service
Dec 02 12:30:23 VM_0_15_centos systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: Unit docker.service entered failed state.
Dec 02 12:30:23 VM_0_15_centos systemd[1]: docker.service failed.
I cant start docker.service after using systemctl restart docker.service
. Before doing this, the docker service works well on my servers.
I tried to add { "storage-driver": "devicemapper" }
to the /etc/docker/daemon.json
. The docker service can be started. But the docker images and the containers are all missing.
sh$ df -h
[docker]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 18G 30G 38% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 24K 1.9G 1% /dev/shm
tmpfs 1.9G 356K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs 380M 0 380M 0% /run/user/0
tmpfs 380M 0 380M 0% /run/user/1000
On the other hand, when I remove { "storage-driver": "devicemapper" }
from /etc/docker/daemon.json
. And then I do mv /var/lib/docker /var/lib/docker_cp
. The docker service can also be started. But all the docker images and containers are missing.
So how to start the docker service with exists images and containers?
sh$ ls /var/lib/docker
drwx--x--x 15 root root 4096 Dec 2 12:53 .
drwxr-xr-x. 37 root root 4096 Dec 2 12:50 ..
drwx------ 2 root root 4096 Nov 13 00:50 builder
drwx--x--x 3 root root 4096 Dec 2 12:12 containerd
drwx------ 8 root root 4096 Dec 2 11:42 containers
drwx------ 4 root root 4096 Dec 2 12:26 devicemapper
-rw-r--r-- 1 root root 187634 Dec 2 12:31 dockerd[11830]: time="2017-12-02T12:30:23.396022007+08:00" level=info msg="libcontainerd: starte
drwx------ 4 root root 4096 Dec 2 12:24 image
drwxr-x--- 3 root root 4096 Nov 13 00:50 network
drwx------ 133 root root 32768 Dec 2 12:53 overlay
drwx------ 4 root root 4096 Dec 2 12:53 plugins
drwx------ 2 root root 4096 Dec 2 12:53 runtimes
drwx------ 2 root root 4096 Nov 13 00:50 swarm
drwx------ 2 root root 4096 Dec 2 12:53 tmp
drwx------ 2 root root 4096 Nov 13 00:50 trust
drwx------ 2 root root 4096 Nov 13 00:50 volumes