我已经安装docker在ubuntu 14.04,它告诉我安装成功。然后我进入sudo docker版本,它返回
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服务docker状态,我得到了
docker start/running,process 8063
我试过sudo docker图像和sudo docker信息,我得到相同的答复:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
我不知道为什么它返回这个,我试图拉ubuntu使用sudo docker拉ubuntu,并得到了
Using default tag: latest Cannot connect to the Docker daemon. Is the docker daemon running on this host?
请告诉我如何解决这个问题,我该如何拉和运行docker镜像。是docker -d和docker deamon一样吗?
您需要将当前用户添加到docker组,如下所示:
sudo usermod -aG docker <your username>
另外,可以使用USER环境变量如:
sudo usermod -aG docker $USER
然后重新启动系统。因为docker documentation说:
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
withsudo
. For this reason,docker daemon always runs as the root
user.To avoid having to use
@H_403_58@sudo
when you use thedocker
command,create a
Unix group calleddocker
and add users to it. When the docker daemon
starts,it makes the ownership of the Unix socket read/writable by the
docker
group.