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条回答
一纸荒年 Trace。
2楼-- · 2019-01-03 01:05

If you are running Docker on OS X, running the following eval has worked for me.

eval "$(docker-machine env default)"

If you'd prefer not to have to run this eval statement on every terminal session, you can add this to your bash_profile:

#Docker
eval "$(docker-machine env default)"

Be sure to restart the terminal session or run source on bash_profile for the changes to take effect.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-03 01:05

I also got the issue "Cannot connect to the Docker daemon. Is the docker daemon running on this host?".

I had forgot to use sudo. Hope it will help some of us.

$:docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$:sudo docker images
REPOSITORY   TAG   IMAGE ID   CREATED   SIZE
查看更多
别忘想泡老子
4楼-- · 2019-01-03 01:06

Linux

To run docker daemon on Linux (from CLI), run:

$ sudo service docker start # Ubuntu/Debian

Note: Skip the $ character when copy and pasting.

On RedHat/CentOS, run: sudo systemctl start docker.

To initialize the "base" filesystem, run:

$ sudo service docker stop
$ sudo rm -rf /var/lib/docker
$ sudo service docker start

or manually like:

$ sudo docker -d --storage-opt dm.basesize=20G

Install docker-machine on Linux

To install machine binaries on Linux:

  • locally:

    install -vm755 <(curl -L https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) $HOME/bin/docker-machine
    
  • global:

    sudo bash -c 'install -vm755 <(curl -L https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) /usr/local/bin/docker-machine'
    

macOS

On macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it.

Install docker-machine on macOS

If you don't have docker-machine command yet, install it by using one of the following methods:

  • Using Brew command: brew install docker-machine docker.
  • manually from GitHub:

    install -v <(curl https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) /usr/local/bin/docker-machine
    

See: Get started with Docker for Mac.

Configure docker-machine on macOS

To start Docker Machine via Homebrew, run:

brew services start docker-machine

To create a default machine (if you don't have one, see: docker-machine ls):

docker-machine create --driver virtualbox default

Then set-up the environment for the Docker client:

eval "$(docker-machine env default)"

Then double-check by listing containers:

docker ps

See: Get started with Docker Machine and a local VM.


Install Docker.app on macOS

Alternatively to above solution, you can install a Docker app by:

brew cask install docker

Check this post for more details. See also: Cannot connect to the Docker daemon on macOS

查看更多
放我归山
5楼-- · 2019-01-03 01:06

If you get the message Can't connect to docker daemon. Is 'docker -d' running on this host?, you can check it by docker version.

If you see the information like Docker Client is running. but Docker Server is not, it's obviously you need to start the Docker server.

In CentOS, you can use service to start or stop the Docker server.

$ sudo service docker stop
$ sudo service docker start

Then, after you type docker version, you will get the information of Docker Client and Docker Server, and the Docker daemon has been started.

查看更多
聊天终结者
6楼-- · 2019-01-03 01:06

I have similar problem. I had to logout and login again to shell because I have just installed Docker and following command didn't show in my environment.

export DOCKER_HOST=127.0.0.1:4243 >> ~/.bashrc
查看更多
小情绪 Triste *
7楼-- · 2019-01-03 01:06

Following Docker's DOC site: Manage Docker as a non-root user

1) Create Docker Group

sudo groupadd docker 

2) Make user belong to docker group to get the group's privileges.

sudo usermod -aG docker $USER

Check whether the DOCKER_HOST environment variable is set for your shell.

env | grep DOCKER_HOST

If it exists,

unset DOCKER_HOST

Then this should work:

docker run hello-world
查看更多
登录 后发表回答