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条回答
Explosion°爆炸
2楼-- · 2019-01-03 00:54

This usually happens when you are not in the docker group. You can add yourself to the docker group with:

sudo usermod -aG docker yourusername

or

sudo usermod -aG docker $(whoami)

After this, you need to logout and log back into the server.

Alternatively, you can sudo every Docker command.

查看更多
我只想做你的唯一
3楼-- · 2019-01-03 00:54

If all the other solutions above don't work you can try checking the ownership of /var/run/docker.sock:

ls -l /var/run/docker.sock

If you're not the owner then change ownership with the command:

sudo chown *your-username* /var/run/docker.sock

Then you can go ahead and try executing the Docker commands hassle-free :D

查看更多
该账号已被封号
4楼-- · 2019-01-03 00:54

I just had the same issue, running on Amazon AWS.

Here's what I attempted:

  • Set up docker-machine locally with already existing AWS instance
  • Used generic setup
  • It kind of connected, but since the remote port was closed, it failed
  • After that, the Docker daemon refused to start up, but running dockerd did work...

It was tested following on the remote machine:

service docker start # Also restart, no success
systemctl start docker # Also restart, no success
dockerd # Success

I removed /var/lib/docker and uninstalled everything, but there was no success after reinstallation. Unfortunately I have no logs stored from failures, but docker.service just refused to start.

However, what finally solved my issue was basically:

sudo usermod -aG docker $(whoami)
查看更多
太酷不给撩
5楼-- · 2019-01-03 00:56

Try to change the Docker configuration file, docker or docker-network in /etc/sysconfig:

(... ~ v1.17)

docker file:

OPTIONS= -H fd://

or (v1.18):

docker-network file:

DOCKER_NETWORK_OPTIONS= -H unix:///var/run/docker.sock
查看更多
狗以群分
6楼-- · 2019-01-03 00:57

I restart Docker after installing it:

$ sudo service docker stop
$ sudo service docker start

And it works.

查看更多
smile是对你的礼貌
7楼-- · 2019-01-03 00:57

I have faced this problem, and I restarted Docker using these commands:

$ sudo service docker stop
$ sudo service docker start

But I did not solve my problem, because I forgot to execute my Docker commands without sudo. For those who faces this problem, try to check that.

Try

$ sudo docker info

instead of this:

$ docker info
查看更多
登录 后发表回答