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

I also received the error message below, after installing the docker and running: docker run hello-world #Cannot connect to the Docker daemon at unix: /var/run/docker.sock. Is the docker daemon running?

Here's a solution, what worked for me. Environment

  • Windows 10 (Don't forget to enable on windows: Settings> Update and Security> Developer mode)
  • Ubuntu 18.04 LTS
  • Docker Desktop version 2.3.0.2 (45183)
    • Enable in Docker Desktop: Expose daemon on tcp: // localhost: 2375 without TLS
    • Docker Desktop must also be running (connected to Docker Hub ... just log in)

After installing ubuntu, update the repository

sudo apt-get update

To use a repository over HTTPS

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Add the official Docker GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Make sure you now have the key with the fingerprint

sudo apt-key fingerprint 0EBFCD88

Update the repository

sudo apt-get update

Update the docker repository

sudo add-apt-repository "deb [arch = amd64] https://download.docker.com/linux/ubuntu $ (lsb_release -cs) stable "

Update the repository again

sudo apt-get update

Command to install the docker in version: 5: 18.09.9 ~ 3-0 ~ ubuntu-bionic

sudo apt-get install docker-ce = 5: 18.09.9 ~ 3-0 ~ ubuntu-bionic docker-ce-cli = 5: 18.09.9 ~ 3-0 ~ ubuntu-bionic containerd.io

Command to set the DOCKER_HOST

export DOCKER_HOST="tcp://0.0.0.0:2375"

Note: put the command above in your profile to start with the ubunto ex: echo "export DOCKER_HOST="tcp://0.0.0.0:2375"" >> ~/.bashrc

Add user to the docker group

sudo usermod -aG docker $USER

Restart ubuntu

(Close and open the ubuntu window again) or run:

source ~/.bashrc

Testing the installation (DO NOT use more sudo before docker commands (it will give an error), the user "root" has already been included in the docker group)

docker run hello-world

The message below should be displayed

Hello from Docker! This message shows that your installation appears to be working correctly.

Note: if it fails, run the command again:

export DOCKER_HOST="tcp://0.0.0.0:2375"

Reference: https://docs.docker.com/engine/install/ubuntu/ Session: INSTALL DOCKER ENGINE

#For other versions of the docker that can be installed with ubuntu, see the repository using the command below: apt-cache madison docker-ce

Then install the desired version of the docker:

sudo apt-get install docker-ce = <VERSION_STRING> docker-ce-cli = <VERSION_STRING> containerd.io

Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to ubuntu

grep's at sign caught as whitespace "E: Unable to locate package python-pip" on Ubuntu 18.04 How to Install pip for python 3.7 on Ubuntu 18? "Repository does not have a release file" error ping: google.com: Temporary failure in name resolution How to install JDK 11 under Ubuntu? How to upgrade Python version to 3.7? Issue in installing php7.2-mcrypt Install Qt on Ubuntu Failed to start mongod.service: Unit mongod.service not found

Examples related to docker

standard_init_linux.go:190: exec user process caused "no such file or directory" - Docker What is the point of WORKDIR on Dockerfile? E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation How do I add a user when I'm using Alpine as a base image? docker: Error response from daemon: Get https://registry-1.docker.io/v2/: Service Unavailable. IN DOCKER , MAC How to fix docker: Got permission denied issue pull access denied repository does not exist or may require docker login Docker error: invalid reference format: repository name must be lowercase Docker: "no matching manifest for windows/amd64 in the manifest list entries" OCI runtime exec failed: exec failed: (...) executable file not found in $PATH": unknown

Examples related to ubuntu-14.04

Yarn install command error No such file or directory: 'install' How to remove docker completely from ubuntu 14.04 Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Docker Error bind: address already in use no target device found android studio 2.1.1 How to use systemctl in Ubuntu 14.04 Android Studio: /dev/kvm device permission denied How to download a folder from github? Ubuntu: Using curl to download an image Compile c++14-code with g++