【Docker】/usr/bin/docker-current: Cannot connect to the Docker daemon at unix

-------------------------------------------------------------------------------------------------linux

|  欢迎关注我的公众号  zclinux_note  第一时间获取关于linux使用的技巧。探索Linux的奥秘   |git

-------------------------------------------------------------------------------------------------docker

报错以下:
/usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See '/usr/bin/docker-current run --help'.
json

message内容:centos

Jul 10 01:07:04 docker systemd: docker.service: main process exited, code=exited, status=1/FAILURE
 tcp

Jul 10 01:07:04 docker systemd: Unit docker.service entered failed state.
Jul 10 01:07:04 docker systemd: Failed to start Docker Application Container Engine.
Jul 10 01:07:04 docker dockerd-current: --label list                            Set key=value labels to the daemon (default [])
Jul 10 01:07:04 docker dockerd-current: --live-restore                          Enable live restore of docker when containers are still running
Jul 10 01:07:04 docker dockerd-current: --log-driver string                     Default driver for container logs (default "json-file")
Jul 10 01:07:04 docker dockerd-current: -l, --log-level string                      Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")ui

Jul 10 01:14:10 docker journal: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simple)' failed
Jul 10 01:14:10 docker journal: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simple)' failed
Jul 10 01:14:39 docker journal: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simple)' failed
Jul 10 01:15:27 docker journal: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simple)' failed
Jul 10 01:17:14 docker kube-controller-manager: W0710 01:17:14.365703    9051 reflector.go:319] pkg/controller/garbagecollector/garbagecollector.go:768: watch of <nil> ended with: 401: The event in requested index is outdated and cleared (the requested history has been cleared [377/32]) [1376]
Jul 10 01:17:39 docker journal: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simple)' failed
 spa

 

解决办法:debug

/lib/systemd/system/docker.service文件(确保万无一失,先备份一份)
 unix

原文件部份内容:

ExecStart=/usr/bin/dockerd-current \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          --init-path=/usr/libexec/docker/docker-init-current \
          --seccomp-profile=/etc/docker/seccomp.json \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
	  $REGISTRIES

这上述部分所有删掉:

并从新写成以下部份内容:

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654

其余参数不变,重启docker

systemctl daemon-reload

systemctl restart docker.service

完成后,查看是否启动正常,而且能够看到版本信息

[root@docker system]# docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64
 Go version:      go1.10.3
 Git commit:      b2f74b2/1.13.1
 Built:           Wed May  1 14:55:20 2019
 OS/Arch:         linux/amd64

Server:  Version:         1.13.1  API version:     1.26 (minimum version 1.12)  Package version: docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64  Go version:      go1.10.3  Git commit:      b2f74b2/1.13.1  Built:           Wed May  1 14:55:20 2019  OS/Arch:         linux/amd64  Experimental:    false