docker-compose无法连接到docker守护进程?

时间:2020-02-19 01:43:56

标签: docker docker-compose

我正在尝试通过docker-compose建立一个docker环境,但是会出错。

$ docker-compose build
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Docker守护程序正在运行

$ sudo systemctl status docker
[sudo] password for mansop:
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-02-19 12:07:27 AEDT; 22min ago
     Docs: http://docs.docker.com
 Main PID: 8972 (dockerd-current)
    Tasks: 22
   Memory: 22.8M
   CGroup: /system.slice/docker.service
           ├─8972 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/l...
           └─8978 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containe...

从centos7存储库安装的Docker:

$ docker --version
Docker version 1.13.1, build 4ef4b30/1.13.1

我尝试根据错误消息设置DOCKER_HOST,但问题仍然存在:

$ echo $DOCKER_HOST
127.0.0.1:2375

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

由于某种原因,我的系统中没有docker组,我的用户不属于docker组,并且docker socket文件不在docker组下。

以下命令解决了我的问题:

sudo useradd docker
usermod aG docker mansop
sudo chown root:docker /var/run/docker.sock