Docker can't connect to docker daemon

2019-01-03 00:32发布

After I update my Docker version to 0.8.0, I get an error message while entering sudo docker version:

Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/19 12:54:16 Can't connect to docker daemon. Is 'docker -d' running on this host?

And I've followed the instructions and entered command sudo docker -d, and I got this:

[/var/lib/docker|2462000b] +job initserver()
[/var/lib/docker|2462000b.initserver()] Creating server
open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory[/var/lib/docker|2462000b] -job initserver() = ERR (1)
2014/02/19 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory

How do I solve the problem?

标签: linux docker
30条回答
smile是对你的礼貌
2楼-- · 2019-01-03 00:57

If regenerating TLS certificates doesn't work

docker-machine regenerate-certs default

Try restarting the docker machine and setting the env variable:

docker-machine restart default
eval $(docker-machine env default)

Check if the machine is running with:

docker-machine ls

or alternatively

docker run hello-world

This worked for me. However, if you still don't have the daemon up, Docker's troubleshooting page details a process for stopping, removing and creating a new machine.

查看更多
走好不送
3楼-- · 2019-01-03 00:58

Try adding the current user to docker group:

sudo usermod -aG docker $USER

Then log out and login.

查看更多
太酷不给撩
4楼-- · 2019-01-03 00:59

Have you tried turning it off and on again? :-)

I had the same issue after upgrading to Docker 1.10.1 on my Mac. I did the following:

On the Docker Quickstart Terminal

$ exit

$ exit

then

docker-machine kill default

then restarted Docker Quickstart Terminal

This solved my problem.

查看更多
Juvenile、少年°
5楼-- · 2019-01-03 01:00

I have the same error and trying docker-machine regenerate-certs or eval.. did not work for me.

This on OS X 10.11.3 (El Capitan) and Docker v1.10.1. I was able to fix it only by deleting and recreating docker-machine again. Source

If running docker-machine ls, it shows you a similar output to the one below;

DOCKER

Unknown

ERRORS

Unable to query docker version: Cannot connect to the docker engine endpoint

Try removing your Docker machine with;

docker-machine rm -f default

Where default is your Docker machine name. Then;

docker-machine create -d virtualbox default

Creates a new Docker machine.

Double check that everything looks normal now (no errors or unknown Docker) with:

docker-machine ls

Finally don't forget to run "$(docker-machine env default)" before you continue or run the Docker Quickstart Terminal which does it for you...

查看更多
够拽才男人
6楼-- · 2019-01-03 01:01
  1. I also had the same issue. The problem was in sockets allocated to docker-daemon and docker-client.
  2. First, permission was not set for the docker-client on docker.sock You can set it using "sudo usermod -aG docker $USER"
  3. Then check your bash file where the docker-client is running, For me it was on 0.0.0.0:2375, while docker-daemon was running on unix socket.(It was set in the configuration file of dockerd).
  4. Just comment the bash-line and it'll work fine.
  5. But if you want to make it work on TCP port instead of unix socket, change the configuration file of dockerd and set it on 0.0.0.0.2375 and keep the line in bash as it is if present or set it to 0.0.0.0:2375.
查看更多
乱世女痞
7楼-- · 2019-01-03 01:03

Ok so I started having this problem today. Then I saw a lot of responses but none seem to have worked for me. First most of the instructions where directed to linux. And for the mac version they were all talking about running 'docker-machine'. I assume you use docker-machine if you install docker toolbox because then docker will be running in a virtual machine for windows and mac platforms. But its 2017 now and docker for mac is really stable hence no need for using the toolbox.

Not sure how the daemon stopped though. But to restart it all I had to do was go "Applications" and double click on the docker icon. I was asked to update and Relaunched which I accepted. After that everything worked like a charm.

查看更多
登录 后发表回答