skip to Main Content
zouz@zouz:~$ docker -v
Docker version 20.10.8, build 3967b7d28e

zouz@zouz:~$ sudo docker info
Client:
 Context:    default
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

and everytime i run docker i get this error.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

help is appreciated.

2

Answers


  1. I was able to solve the connectivity problem with the .sock by touching some configuration files

    In /etc/init/docker.conf file changed the variable "DOCKER_SOCKET" to the path where my sock is running

    DOCKER_SOCKET=/home/user/.docker/desktop/docker.sock
    

    then in the /lib/systemd/system/docker.socket file in the variable
    We also change the value of ListenStream to the same path of the sock that we have put in the previous file

    [Unit]
    Description=Docker Socket for the API
    
    [Socket]
    ListenStream=/home/user/.docker/desktop/docker.sock
    SocketMode=0660
    SocketUser=root
    SocketGroup=docker
    
    [Install]
    WantedBy=sockets.target
    

    when we have the two files changed and saved we can restart the services.

    systemctl stop docker.service
    systemctl stop docker.service
    
    systemctl daemon-reload
    
    systemctl start docker.service
    systemctl start docker.service
    
    Login or Signup to reply.
  2. if you are facing following error when running docker –

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

    or

    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down
    

    Run following commands

    $ sudo systemctl status docker
    
    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down
    
    

    The reason is that you are trying to use systemd command to manage services on Linux but your system doesn’t use systemd and (most likely) using the classic SysV init (sysvinit) system.
    run following command to confirm if its above case

    $ ps -p 1 -o comm=
    init 
    

    so now you check again the status using

    $ sudo service docker status
     * Docker is not running
    

    you can start docker using the following command

    sudo service docker start
     * Starting Docker: docker
    

    for more detail pls refer following link
    https://linuxhandbook.com/system-has-not-been-booted-with-systemd/

    Systemd command Sysvinit command
    systemctl start service_name service service_name start
    systemctl stop service_name service service_name stop
    systemctl restart service_name service service_name restart
    systemctl status service_name service service_name status
    systemctl enable service_name chkconfig service_name on
    systemctl disable service_name chkconfig service_name off
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search