How to Fix Cannot Connect to the Docker Daemon at unix:///var/run/docker.sock Issue?

Docker is getting more and more popular with its capability to produce, emplace, and run operations using holders fluently. Containers allow inventors to package an operation with all its libraries and dependencies before planting it as one full package. Installing Docker on Linux is fairly easy. All you need to do is run a couple of commands in the Terminal window, and you’re good to go.

Docker Connection Error
Docker Connection Error

Still, this might not be the same for all druggies, indeed after a successful installation. One of the most common arising error is Cannot connect to the Docker daemon at (unix/// var/ run/docker.sock. Is the docker daemon running?) This error can arise when running colorful docker commands like docker run, docker word, docker pull, docker stop,etc.

Cause of the Error?

After entering multitudinous inventors ’ complaints, we decided to dive in and come up with effective results. Some of the reasons that spark this error include

The Docker daemon isn’t running.
Docker doesn’t arrestment fairly.
Lack of root boons to start the docker service.
Now that you have a introductory understanding of the problem cause, let’s look at the colorful results available for you.

1. Start the Docker service with systemctl

Still, there’s a high probability chance the Docker service isn’t running, If you have just completed a Docker’s fresh installation on Ubuntu or rebooted your PC. Docker daemon (dockerd) is the system service for docker. This service handles colorful Docker objects like images, holders, networks, and volumes and listens to the Docker API requests.

The Systemctl command comes to replace the old SysV init system, and it manages systemd services running on Linuxsystems.However, do n’t worry; use the service command as described below, If you don’t have systemctl in your system.

Note: This system only works for druggies who installed Docker with the APT package manager. However, relate to result 5 below, If you installed Docker via SNAP.

  1. Open the Terminal and type the unmask docker command:
    sudo systemctl unmask docker
  2. After the docket unit is unmasked, now start the docker daemon with systemctl command:
    systemctl start docker
  3. To check if docker is running and working properly type the status command to check:
    systemctl status docker
    Checking status
    Checking status

2. Clean a ‘Failed Docker Pull’ and Start Docker service

There are cases where you might suddenly close Docker while pulling a vessel. similar situations will mask the docker.service and docker. socket lines. Docker.socket is a train located at ‘/ var/ run/docker.sock ’ and is used to communicate with the Docker daemon. We’ll need to unmask the two- unit lines – docker. service and docker.daemon before pacing to start docker.

  1. Open Terminal on your system and type the following commands:
    systemctl unmask docker.service
    systemctl unmask docker.socket
    systemctl start docker.service
    docker systemctl commands
    docker systemctl commands
  2. Now open terminal again and now type the following commands with admin rights:
    sudo su
    service docker stop
    cd /var/run/docker/libcontainerd
    rm -rf containerd/*
    rm -f
    service docker start

3. Start Dockerd (Docker Daemon) Service

Dockerd is the Docker daemon which listens to Docker APIs and manages the colorful Docker objects. Dockerd can be used as an volition to the command ‘$ systemctl start docker‘ which is also used to start the Docker daemon.

  1. Open Terminal and start dockerd by typing the following command:
    sudo dockerd

4: Start Docker with the Service command

Still, also the systemctl command won’t work for you, If you’re using the SysV init system. We’ll need to use the service command to start docker daemon.

  1. Type following command in the Terminal:
    sudo service --status-all
    sudo service docker start
Back to top button