在Ubuntu 16.04上无法通过unix:///var/run/docker.sock连接到Docker守护程序

时间:2018-11-21 02:37:44

标签: docker

偶然地,我的泊坞窗出了错,无法启动。

docker ps出现以下错误

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

systemctl status docker.service提供以下输出:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/docker.service.d
       └─override.conf
   Active: failed (Result: start-limit-hit) since Tue 2018-11-20 18:27:11 PST; 11s ago
 Docs: https://docs.docker.com
  Process: 16519 ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime (code=exited, status=1/FAILURE)
 Main PID: 16519 (code=exited, status=1/FAILURE)

Nov 20 18:27:09 loccalhost systemd[1]: Failed to start Docker Application Container Engine.
Nov 20 18:27:09 loccalhost systemd[1]: docker.service: Unit entered failed state.
Nov 20 18:27:09 loccalhost systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 20 18:27:11 loccalhost systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Nov 20 18:27:11 loccalhost systemd[1]: Stopped Docker Application Container Engine.
Nov 20 18:27:11 loccalhost systemd[1]: docker.service: Start request repeated too quickly.
Nov 20 18:27:11 loccalhost systemd[1]: Failed to start Docker Application Container Engine.
Nov 20 18:27:11 loccalhost systemd[1]: docker.service: Unit entered failed state.
Nov 20 18:27:11 loccalhost systemd[1]: docker.service: Failed with result 'start-limit-hit'.

2 个答案:

答案 0 :(得分:0)

skyuua提到的同一线程中的more recent answer提出以下建议(它将-H fd://更改为-H unix://)

  

sudo systemctl编辑docker.service

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:// -H tcp://127.0.0.1:2375

之后

  

sudo systemctl守护程序重新加载

     

sudo systemctl重新启动docker.service

在具有docker 18.0.3的Ubuntu 16.04上,这重写了文件 /etc/systemd/system/docker.service.d/override.conf ,该文件允许docker正确启动。

答案 1 :(得分:0)

我们运行了sudo apt-get update,我们的docker版本也得到了更新,它从18.09.1更改为18.09.3,而docker变成了麻烦。在网上进行挖掘之后,我会寻找可以为我们解决问题的解决方案。

sudo systemctl edit docker.service 

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd-ce -H unix://var/run/docker.sock -H tcp://0.0.0.0:2375

然后重新启动服务

sudo systemctl restart docker.service