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条回答
够拽才男人
2楼-- · 2019-01-03 01:14

To fix, you need to issue the following commands in the terminal. I'll explain each step:

# Uninstall Docker from apt packages
$ sudo apt-get remove docker docker.io

# Remove it from the libraries just to be
# sure it's gone forever
$ sudo rm -rf /var/lib/docker/*

Now, if you want to simplify things and get more time, you can run my init script with the parameter installDocker:

# Pull the init script from GitHub
$ wget https://github.com/dminca/dotfiles/blob/master/init

# Add rights to run the script
$ chmod 755 init

# Just run the script with the installDocker parameter
$ ./init installDocker

A reboot is optional, but I suggest you do it to be sure all runs smoothly.

查看更多
做自己的国王
3楼-- · 2019-01-03 01:18

Do a ps aux | grep docker to see if the daemon is running. If not run /etc/init.d/docker start

查看更多
混吃等死
4楼-- · 2019-01-03 01:18

I got the same problem. In CentOS 6.5:

ps aux |grep `cat /var/run/docker.pid`

If it shows no Docker daemon process exists, then I type:

docker -d

Then Ctrl + D to stop Docker. Because we use the -d option, Docker will run as daemon. Now we can do:

service docker start

Then I can do a docker pull centos. That's all.

NOTE: If these do not work, you can try yum update, and then repeat these again, because I yum install before these.

查看更多
别忘想泡老子
5楼-- · 2019-01-03 01:20

The best way to find out why Docker isn't working will be to run the daemon manually.

$ sudo service docker stop
$ ps aux | grep docker  # do this until you don't see /usr/bin/docker -d
$ /usr/bin/docker -d

The Docker daemon logs to STDOUT, so it will start spitting out whatever it's doing.

Here was what my problem was:

[8bf47e42.initserver()] Creating pidfile
2015/01/11 15:20:33 pid file found, ensure docker is not running or delete /var/run/docker.pid

This was because the instance had been cloned from another virtual machine. I just had to remove the pidfile, and everything worked afterwards.

Of course, instead of blindly assuming this will work, I'd suggest running the daemon manually one more time and reviewing the log output for any other errors before starting the service back up.

查看更多
一纸荒年 Trace。
6楼-- · 2019-01-03 01:20

If you are running on OS X using Docker tool, follow this.

Restart the daemon and configure your environment:

docker-machine restart

And then

docker-machine env

Finally,

eval $(docker-machine env)

To test the daemon is running:

docker ps -a or docker-machine ls. This will list all containers.

查看更多
劳资没心,怎么记你
7楼-- · 2019-01-03 01:20

I had the same problem running Docker 1.10 on Ubuntu 14.04 and none of the given answers worked. For me, the fix was to specify the storage driver when running the Docker daemon.

sudo docker daemon --storage-driver=devicemapper
查看更多
登录 后发表回答