Docker-Compose can't connect to Docker Daemon

2019-03-08 22:55发布

I am getting an error message saying I can't connect to the docker daemon. I have looked into other people's answers who have had similar issues but it hasn't helped. I am running the version of Ubuntu 15.10. I will try to provide all the info I have.

root@# docker-compose -f docker-compose-deps.yml up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

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

Docker Version

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

Docker-Compose Version

root@# docker-compose --version
docker-compose version 1.5.2, build 7240ff3

This is what happens if I try to stop or start the service...

root@# sudo service docker stop
stop: Unknown instance: 
root@# sudo service   docker start
docker start/running, process 5375

If I run ps aux | grep docker

root@# ps aux | grep docker
root      4233  0.0  0.0  13692  2204 pts/15   S+   10:27   0:00 grep --color=auto docker

Any help would be greatly appreciated. Let me know if you may need anymore information.

9条回答
地球回转人心会变
2楼-- · 2019-03-08 23:20

I got this error when there were files in the Dockerfile directory that were not accessible by the current user. docker could thus not upload the full context to the daemon and brought the "Couldn't connect to Docker daemon at http+docker://localunixsocket" message.

查看更多
该账号已被封号
3楼-- · 2019-03-08 23:20

I used Ubuntu 16.04 and found this problem too when I used docker-compose. I fixed it by running this command.

$ sudo systemctl start docker
$ sudo docker-compose build
查看更多
看我几分像从前
4楼-- · 2019-03-08 23:21

I found this and it seemed to fix my issue.

GitHub Fix Docker Daemon Crash

I changed the content of my docker-compose-deps.yml file as seen in the link. Then I ran docker-compose -f docker-compose-deps.yml up -d. Then I changed it back and it worked for some reason. I didn't have to continue the steps in the link I provided, but the first two steps fixed the issue for me.

查看更多
聊天终结者
5楼-- · 2019-03-08 23:26

In my case your docker service might be stopped

Command to start docker service:

$ sudo systemctl start docker

Command to verify if it start:

$ sudo docker run hello-world

查看更多
霸刀☆藐视天下
6楼-- · 2019-03-08 23:38

I had the same error, after 15 min of debugging. Turns out all it needs is a sudo :) Check out [Create a Docker group] here https://docs.docker.com/engine/installation/linux/ubuntulinux/ to get rid of the sudo prefix.

查看更多
Animai°情兽
7楼-- · 2019-03-08 23:39

I had this problem and did not want to mess things up using sudo. When investigating, I tried to get some info :

docker info

Surprinsingly, I had the following error :

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http:///var/run/docker.sock/v1.38/info: dial unix /var/run/docker.sock: connect: permission denied

For some reason I did not have enough privileges, the following command solved my problem :

sudo chown $USER /var/run/docker.sock

Et voilà !

查看更多
登录 后发表回答