docker报错(ubuntu16.04)

root@stone-vir:/dev/mapper# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
root@stone-vir:/dev/mapper# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since 四 2017-11-09 10:48:12 CST; 2min 25s ago
     Docs: https://docs.docker.com
  Process: 7524 ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)
 Main PID: 7524 (code=exited, status=1/FAILURE)

11月 09 10:48:11 stone-vir systemd[1]: Starting Docker Application Container Engine...
11月 09 10:48:11 stone-vir dockerd[7524]: time="2017-11-09T10:48:11.674535026+08:00" level=info msg="libcontainerd: new containerd process, pid: 7530"
11月 09 10:48:12 stone-vir dockerd[7524]: time="2017-11-09T10:48:12.725755254+08:00" level=info msg="[graphdriver] using prior storage driver \"aufs\""
11月 09 10:48:12 stone-vir dockerd[7524]: time="2017-11-09T10:48:12.734404927+08:00" level=fatal msg="Error starting daemon: layer does not exist"
11月 09 10:48:12 stone-vir systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
11月 09 10:48:12 stone-vir systemd[1]: Failed to start Docker Application Container Engine.
11月 09 10:48:12 stone-vir systemd[1]: docker.service: Unit entered failed state.
11月 09 10:48:12 stone-vir systemd[1]: docker.service: Failed with result 'exit-code'.
11月 09 10:48:12 stone-vir systemd[1]: docker.service: Start request repeated too quickly.
11月 09 10:48:12 stone-vir systemd[1]: Failed to start Docker Application Container Engine.

Process: 7524 ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)

原因:这个变量没有获取到值

解决:手动赋值给这个变量

方法:在/etc/default/docker中添加DOCKER_OPTS="-s overlay2"

官方文档建议ubuntu16.04使用overlay2

相关文档:https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#docker-ee-customers

root@stone-vir:/home/stone# vim /etc/default/docker 

# Here in Debian, this file is sourced by:
#   - /etc/init.d/docker (sysvinit)
#   - /etc/init/docker (upstart)
#   - systemd's docker.service

# Use of this file for configuring your Docker daemon is discouraged.

# The recommended alternative is "/etc/docker/daemon.json", as described in:
#   https://docs.docker.com/v1.11/engine/reference/commandline/daemon/#daemon-configuration-file

# If that does not suit your needs, try a systemd drop-in file, as described in:
#   https://docs.docker.com/v1.11/engine/admin/systemd/#custom-docker-daemon-options
DOCKER_OPTS="-s overlay2"

重启载入就不会再报错

root@stone-vir:~# systemctl restart docker
root@stone-vir:~# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.6
Storage Driver: overlay2

但会出现一个问题:之前的docker images会被清掉。需要再docker pull。

相关文档:

https://github.com/moby/moby/issues/29868

https://stackoverflow.com/questions/37227349/unable-to-start-docker-service-in-ubuntu-16-04

https://github.com/moby/moby/issues/22371

猜你喜欢

转载自my.oschina.net/u/3331172/blog/1570382