Docker 安装后无法使用

Docker not working after installation

我尝试使用 the linux method 安装 docker。 但是,当执行命令 $docker run hello-world 时,它输出:

docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.

对此可以做些什么?

您必须 运行 此命令为 sudo

sudo docker run hello-world

这将为您提供足够的权限来执行该操作。

如果您想让您的用户无需 sudo 即可 运行g docker,请查看 this answer

首先确保守护进程是 运行:

$ps aux|grep "docker daemon"|grep -v "grep"

A) 守护进程未启动(ps 未返回任何行)

启动不工作的守护进程:

$sudo /usr/bin/docker daemon -H unix:///var/run/docker.sock

或将其作为服务启动:

$sudo /usr/sbin/service docker start

此时守护进程启动。

B) 守护进程启动

ps 所示:

[..] /usr/bin/docker daemon -H unix:///var/run/docker.sock

您可以使用第一个容器:

$sudo docker run hello-world.


sudo 和 docker

如果您想使用 docker 而不是 sudo(您应该这样做,但您必须注意安全警告!)一个 good read of this will help you.