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

博主在网上找了不少关于该问题的解决方法,可是都未能解决,因而本身研究了一下,发现是配置的问题。docker


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

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

[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指定启动的本地端口。ui

而后,systemctl daemon-reload/ systemctl restart docker.service / unix

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

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