Docker can't connect to docker daemon

LiJung picture LiJung · Feb 19, 2014 · Viewed 634.1k times · Source

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?

Answer

molavec picture molavec · Nov 8, 2015

Linux

The Post-installation steps for Linux documentation reveals the following steps:

  1. Create the docker group.
    sudo groupadd docker
  2. Add the user to the docker group.
    sudo usermod -aG docker $(whoami)
  3. Log out and log back in to ensure docker runs with correct permissions.
  4. Start docker.
    sudo service docker start

Mac OS X

As Dayel Ostraco says is necessary to add environments variables:

docker-machine start # Start virtual machine for docker
docker-machine env  # It's helps to get environment variables
eval "$(docker-machine env default)" # Set environment variables

The docker-machine start command outputs the comments to guide the process.