612

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
LiJung
  • 7,649
  • 6
  • 27
  • 30
  • 10
    Did you use sudo when running docker -d? – Ben Whaley Feb 19 '14 at 16:16
  • I notice that in the error it says `no such file or directory[/var/lib/docker|2462000b]`. Does `/var/lib/docker` exist on your system? If not then I think you need to reinstall Docker. – Ben Whaley Feb 20 '14 at 05:46
  • 3
    I have the same problem (can't connect to a daemon that 'ps' shows is still running), except I don't get any 'file not found' messages when starting the daemon. /var/lib/docker does exist. – Jonathan Hartley Mar 24 '14 at 22:00
  • Are you using docker on a VPS? – pigletfly Sep 06 '14 at 06:41
  • Install docker desktop from here, it will solve it. https://docs.docker.com/docker-for-mac/install/ – Guy Assaf Mar 12 '20 at 07:07
  • Complete noob here, but what worked for me is to actually run docker(blue whale shows up), especially after a system boot, before typing away docker commands on the terminal :) – Samir K Apr 16 '20 at 01:59

46 Answers46

776

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.

Olivier Dagenais
  • 1,482
  • 2
  • 18
  • 20
molavec
  • 8,848
  • 1
  • 27
  • 22
  • Yes. This was the problem for me. I added my user to the docker group and now I can connect to the daemon. Thanks – Bogdan Dec 09 '15 at 05:08
  • FWIW, the link to the specific section is [this](https://docs.docker.com/engine/installation/ubuntulinux/#create-a-docker-group) – asymmetric Jan 03 '16 at 12:16
  • 24
    If, for some reason, you don't want to logout, you can use `newgrp` command to start a new shell in this new group. Like this: `newgrp docker`. – Denilson Sá Maia Mar 18 '16 at 18:20
  • sudo chown $USER:$USER /path/to/docker/binary – Ivor Scott Oct 03 '16 at 17:40
  • 1
    I had no time to restart bash. So `alias docker='sudo docker'` did the trick. :p – LovaBill Nov 02 '16 at 09:59
  • Got this error "Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details." – Gaurav Sharma Oct 09 '17 at 16:47
  • @Guarav Sharma What did it show "systemctl status docker.service" and "journalctl -xe"?? Maybe, if you copy response in pastebin.com tool we can help yoy better. – molavec Oct 10 '17 at 13:49
  • Awesome. This fixed my issue from https://github.com/wurstmeister/kafka-docker/issues/100 – Pavan Jadda Jan 29 '18 at 20:31
  • On Ubuntu 18.04 with Gnome, I had to restart the system for this to work. Just logging out and back in didn't work :/ – Zoltán Jun 11 '18 at 11:32
  • For the NOOBS like me: "Log out and log back in" means to log out of your account, i.e. reboot your computer. It does not mean log out of the terminal (exit) and log back in (open the terminal). That will do nothing. – Ike Dec 03 '20 at 05:45
  • 1
    For Linux, if you want Docker to start on boot you con [configure `systemd`/`upstart`/`chkconfig` to start docker on boot](https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot). systemd: `sudo systemctl enable docker`, chkconfig: `sudo chkconfig docker on`, upstart is on by default. – Steven C. Howell Jan 14 '21 at 20:19
207

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

kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 2
    sudo service docker start works with Docker 1.9.1 on Ubuntu 14.04 –  Feb 03 '16 at 12:12
  • thanks. this is what worked for me on Ubuntu 14.04. everything else failed. – nyxee Aug 15 '17 at 00:41
  • This is the only thing that worked for me on Mac OSX with hardware older than 2010. I had to install `docker-toolbox` from https://docs.docker.com/toolbox/toolbox_install_mac/ – Vikram Oct 01 '17 at 04:21
  • 2
    I needed to install docker-compose, docker-machine and docker via Homebrew then it worked fine! – Entalpi Jan 26 '18 at 08:07
  • I had this problem on CentOS 7.6 with docker 18 and `sudo rm -rf /var/lib/docker` and then restarting did the trick. I was really stuck and no other solution worked for me. – Ashkan May 18 '20 at 09:56
143

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dayel Ostraco
  • 1,753
  • 1
  • 13
  • 15
  • 4
    Same here, if I try this alone I often get `Error checking TLS connection: Host is not running`... running this eval after the command `docker-machine start default` did the trick. – Emilio Ferrucci May 02 '16 at 17:28
101

After a detailed investigation, this issue seems to happen every time after Mac OS X is rebooted (or the Docker virtual machine is restarted) which prevents the Docker client from connecting to the Docker daemon.

To solve the issue, you can either:

A) Reinstall Docker Toolbox using the official installer (https://www.docker.com/products/docker-toolbox), or simply

B) Run the following commands in order:

# First make sure that the virtual machine is running
docker-machine start default

# Regenerate TLS connection certs, requires confirmation
docker-machine regenerate-certs default

# Finally, set env
eval "$(docker-machine env default)"

C) Same as (B), you can also copy and paste the following line to run all of the three commands:

docker-machine start default; docker-machine regenerate-certs default; eval "$(docker-machine env default)"

In case you get the following error:

Error getting SSH command: Something went wrong running an SSH command!
command : cat /etc/os-release
err     : exit status 255
output  :

just re-run the three commands another time, and it should work the second time.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
K.A.D.
  • 3,648
  • 3
  • 34
  • 35
53

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.

nPcomp
  • 8,637
  • 2
  • 54
  • 49
41

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kevthanewversi
  • 3,686
  • 4
  • 27
  • 27
  • 1
    I have started with this answer, and this helped me! – Andrzej Martyna Aug 02 '17 at 14:23
  • 3
    Problem with this approach is that, you have to repeat this step every time the daemon is restarted – MFIhsan Aug 31 '17 at 19:20
  • Hi @MFIhsan a smart sys-admin would tell you to simply create a bash script of those commands and & add it to crontab to have it run at reboot/startup as explained here > https://stackoverflow.com/a/29247942/3469960 – kevthanewversi Oct 18 '17 at 11:46
  • 2
    A common user should never own a sock! If you don't own the sock then make sure you're in the wheel group and the group the sock belongs to...not the sock owners group! – Paul Allsopp Apr 06 '19 at 22:20
  • Does this `sudo chown $(whoami) /var/run/docker.sock` also works? – Ibrahim.H Jul 23 '20 at 17:05
  • 1
    @kevthanewversi I disagree that a smart sysadmin would do that crontab black magic... it's a bad thing to do, because you're hijacking ownership of the file. Perhaps things were different when you wrote this answer, but the appropriate thing to do is have the user trying to access the file in the group that the file belongs to. Ownership of this file should be as specified: `srw-rw---- 1 root docker 0 May 7 13:07 /var/run/docker.sock`. Adding the user with problems to the docker group is all that is needed to be done... – dddJewelsbbb May 07 '21 at 17:14
29

You can use the command

sudo service docker stop && sudo service docker start

OR

sudo service docker restart

to simply restart it.

kvadityaaz
  • 1,441
  • 1
  • 16
  • 23
19

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.

Robert Elwell
  • 6,598
  • 1
  • 28
  • 32
17

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

Reza S
  • 9,480
  • 3
  • 54
  • 84
16

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shawn Wang
  • 761
  • 8
  • 9
  • 2
    `sudo service docker start` also worked for me on Ubuntu 14.04. – funroll Jul 19 '16 at 16:18
  • Cent os 7, have to do it each time i start docker. – Paddy Dec 07 '16 at 01:00
  • @Paddy You need to enable the service after stating it, and it will run if the system is started and stay running in the background. – Paul Allsopp Apr 06 '19 at 22:23
  • All these answers that say: "You need to sudo systemctl start docker" always assume there is a docker service to start. If there were any issues installing docker, a service configuration file may not even exist, in which case you'de get: "Unit docker.service not loaded" – Paul Allsopp Apr 06 '19 at 22:25
16

Use Docker CE app

macOS

Use the new Docker Community Edition app for macOS. For example:

  1. Uninstall all Docker Homebrew packages which you've installed so far:

     brew uninstall docker-compose
     brew uninstall docker-machine
     brew uninstall docker
    
  2. Install an app manually or via Homebrew-Cask:

     brew install --cask docker
    

Note: This app will create necessary links to docker, docker-compose, docker-machine, etc.

  1. After running the app, checkout the a Docker whale icon in the status menu.
  2. Now you should be able to use docker, docker-compose, docker-machine commands as usual in the Terminal.

Related:

Linux/Windows

Download the Docker CE from the download page and follow the instructions.

Sean Yap
  • 3
  • 2
kenorb
  • 155,785
  • 88
  • 678
  • 743
12

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
kayn
  • 673
  • 5
  • 14
12

I restart Docker after installing it:

$ sudo service docker stop
$ sudo service docker start

And it works.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Galley
  • 493
  • 6
  • 9
9

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Taha Emara
  • 140
  • 1
  • 5
8

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...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kerem
  • 2,867
  • 24
  • 35
8

I knew that there are plenty of answers already in this post. Just I would like to add one simple answer that is solved the above mentioned problem .

sudo systemctl start docker

Run the above command and it will start all the docker related threads/services.

8

At April 2020 on MacOS Catalina, you just need to open the desktop application:

docker app running

Brhaka
  • 1,622
  • 3
  • 11
  • 31
Amr
  • 433
  • 5
  • 12
8

Run the following command:

docker context use default
7

Try adding the current user to docker group:

sudo usermod -aG docker $USER

Then log out and login.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dormi330
  • 1,273
  • 11
  • 18
7

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
blasrodri
  • 448
  • 5
  • 16
6

I had the same problem - "Can't connect to docker daemon." (except I didn't get any 'file not found' errors on trying to start the server.)

'ps' showed that "/usr/bin/docker -d" was still running

I realised that I'd never actually succeeded in running the server myself though. Every attempt had produced

...
2014/03/24 21:57:29 pid file found, ensure docker is not running or delete /var/run/docker.pid

So I belatedly realised that installing docker had maybe registered the daemon with upstart, which had started it for me. Hence, trying to kill the daemon to manually restart it fails (operation not permitted). So I did a

sudo kill -9 <PID>

on the daemon process. Another daemon immediately took its place, and this new one DOES now let my CLI client connect:

$ sudo docker info
Containers: 0
Images: 0
Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 0
WARNING: No memory limit support
WARNING: No swap limit support
Jonathan Hartley
  • 15,462
  • 9
  • 79
  • 80
5

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)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deko
  • 1,028
  • 2
  • 15
  • 24
5

LINUX

you can use this answer https://stackoverflow.com/a/33596140/13997503 and even after using this you still get the same error. then you might have previously installed docker desktop and now switching to docker-engine

you can remove the docker desktop service files using this command

$ rm -rf ~/.docker
Rahul Gupta
  • 166
  • 3
  • 7
4

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
wuranbo
  • 101
  • 7
  • This step was important for me in diagnosing my docker problem after a hardlockup on my machine. But the command I had to run to get this docker output was `sudo /usr/bin/dockerd` with no flags. Ubuntu 18. – Kent Feb 08 '21 at 17:38
4

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ermias K
  • 106
  • 5
3

The Docker Service may not be running.

If you are on a RedHat/Fedora/CentOS, please try this:

sudo systemctl start docker

If you are on Ubuntu/Debian:

sudo service start docker

Docker will start running on your host and respective port.

Allan Sene
  • 459
  • 4
  • 15
Aamir M Meman
  • 1,645
  • 14
  • 15
2

To fix this issue, I had to enable the docker service:

sudo systemctl enable /usr/lib/systemd/system/docker.service
Bill Zelenko
  • 2,606
  • 1
  • 17
  • 26
1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel Andrei Mincă
  • 4,446
  • 2
  • 19
  • 30
1

Check if you are using Docker Machine :)

Run docker-machine env default should do the trick.

Because according to documentation:

Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands. You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like AWS or Digital Ocean.

Using docker-machine commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon, and configure a Docker client to talk to your host.

Point the Machine CLI at a running, managed host, and you can run docker commands directly on that host. For example, run docker-machine env default to point to a host called default, follow on-screen instructions to complete env setup, and run docker ps, docker run hello-world, and so forth.

https://docs.docker.com/machine/overview/

Bob
  • 2,263
  • 5
  • 21
  • 30
1

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yatit Thakker
  • 522
  • 5
  • 4
1
  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.
1

I had a similar issue.

In my case the solution was to remove a deprecated version of docker. This I assume was causing some conflicts.

On ubuntu:

sudo apt remove docker

solved the problem for me

Erich
  • 1,902
  • 1
  • 17
  • 23
1

you can run the daemon with the following command:

sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &

The script leaves the daemon running in the background, and with the Docker ready you can test that it is accepting commands.

sudo docker info

for more information check this out: https://www.upcloud.com/support/how-to-configure-docker-swarm/

1

If you use gitlab-ci / gitlab-runners you get that error if you don't have permissions to access /var/run/docker.sock.

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

To solve the problem:

sudo usermod -aG docker gitlab-runner

Verify with:

sudo -u gitlab-runner -H docker info

Hope that helps.

Tobias Ernst
  • 4,214
  • 1
  • 32
  • 30
1

A lot of answers already but in the hope that this helps someone. This is an issue that occurs when you install docker via snap. Running via sudo would allow you to connect to the daemon, but this leads to other issues. The solution is to perform some steps BEFORE you install the snap package making the complete list of steps:

sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
sudo snap install docker

After doing this, docker will connect to the daemon and work without sudo, no restart required.

https://github.com/docker-archive/docker-snap/issues/1#issuecomment-423778054

Imre_G
  • 2,468
  • 1
  • 17
  • 33
1

My problem was, that default path of docker.sock was not where docker daemon was.

My default was /home/user/.docker, but docker daemon was in /var/bin.

i did set env variable to set correct address and that fixed the issue

export DOCKER_CONFIG = '/var/bin'

https://docs.docker.com/engine/reference/commandline/cli/

I installed docker desktop on ubuntu so that might be the issue or why my DOCKER_CONFIG was not set right.

Ali Amjid
  • 51
  • 4
0

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
Community
  • 1
  • 1
0

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.

Community
  • 1
  • 1
JackNova
  • 3,911
  • 5
  • 31
  • 49
0

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.

nikheel
  • 1
  • 1
0

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
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
0

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.

Stylishcoder
  • 1,142
  • 1
  • 11
  • 21
0

On the Mac OS-X, this could just mean the docker installation is out-dated or not running. Simply download the latest docker from the offical site and install it.

Worked for me.

ABCD
  • 7,914
  • 9
  • 54
  • 90
0

With Docker installed with snap, I sometimes encounter the OP's error upon rebooting my machine. In my case, running sudo snap logs docker revealed an error in the logs:

Error starting daemon: pid file found, ensure docker is not running or delete /var/snap/docker/423/run/docker.pid

After running sudo rm /var/snap/docker/423/run/docker.pid, I can start Docker normally.

Remolten
  • 2,614
  • 2
  • 25
  • 29
0

Usually this never happens. But one day the message appeared (as bellow) and a simple reboot fixed it

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Max Carroll
  • 4,441
  • 2
  • 31
  • 31
0

well you can set the Docker CLI to use the local Docker daemon as the current context:

docker context use default

Deepanshu Mehta
  • 1,119
  • 12
  • 9
0

Step 1: run bleow command in terminal 1 same server.

sudo dockerd

Step 2: in terminal 2 same server.

docker ps

It should resolved