完美解决Cannot connect to the Docker daemon at tcp://localhost:4243. Is the docker daemon running?

博主在网上找了很多关于该问题的解决方法,但是都未能解决,于是自己研究了一下,发现是配置的问题。


分析问题:在本地的4243端口上没有找到docker的守护进程。

解决问题:修改配置文件/etc/systemd/system/multi-user.target.wants/docker.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

将参数ExecStart改成上述值,即为docker指定启动的本地端口。

然后,systemctl daemon-reload/ systemctl restart docker.service / 

分别运行上述命令进行docker重启,重启成功!

这样你就可以不用再sudo去操作docker命令了!!(tips大前提:你当前的用户必须已经添加到了root组 gpass -a USER root).
 

你可能感兴趣的:(docker)