无法连接到 Docker 守护程序.docker 守护进程是否在这台主机上运行? [英] Cannot connect to the Docker daemon. Is the docker daemon running on this host?

查看:131
本文介绍了无法连接到 Docker 守护程序.docker 守护进程是否在这台主机上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 ubuntu 14.04 上安装了 docker,它告诉我安装成功.然后我输入sudo docker version,它返回

I have installed docker on ubuntu 14.04, it told me installed successfully. Then I entered sudo docker version, it returned

Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

我输入了sudo service docker status,我得到了

docker start/running, process 8063

我尝试了 sudo docker imagessudo docker info,我得到了相同的回复:

I tried sudo docker images and sudo docker info, I got the same reply:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

我不知道它为什么返回这个,我尝试使用 sudo docker pull ubuntu 拉 ubuntu,然后得到

I do not know why it returned this, I tried to pull ubuntu using sudo docker pull ubuntu, and got

Using default tag: latest
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

请告诉我如何解决这个问题,如何拉取和运行 docker 镜像.docker -ddocker deamon 一样吗?

Please tell me how can I solve this problem, how can I pull and run docker image. And is docker -d the same as docker deamon?

推荐答案

您需要将当前用户添加到 docker 组,如下所示:

You need to add your current user to docker group like following:

sudo usermod -aG docker <your username>

此外,您可以使用 USER 环境变量,例如:

Also, you can use USER environment variable like:

sudo usermod -aG docker $USER

然后重新启动系统.正如 docker 文档 所说:

Then restart the system. As the docker documentation says:

docker 守护进程绑定到 Unix 套接字,而不是 TCP 端口.默认情况下Unix 套接字由用户 root 拥有,其他用户可以访问它使用 sudo.因此,docker daemon 始终以 root 身份运行用户.

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo. For this reason, docker daemon always runs as the root user.

为避免在使用 docker 命令时必须使用 sudo,请创建一个Unix 组名为 docker 并向其添加用户.当 docker 守护进程启动,它使 Unix 套接字的所有权由docker 组.

To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

这篇关于无法连接到 Docker 守护程序.docker 守护进程是否在这台主机上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆