Can't use docker at VPS ubuntu 20.04.5 LTS


Can anyone help me please?

My docker is not creating /var/run/docker.sock.

Check this out:

root@vmi414881:/var/run# systemctl  start docker
root@vmi414881:/var/run# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
root@vmi414881:/var/run# ls  crond.reboot  dbus  docker  reboot-required  reboot-required.pkgs  unattended-upgrades.lock
root@vmi414881:/var/run# systemctl status docker.service
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-02-02 22:30:54 CET; 3min 10s ago
TriggeredBy: ● docker.socket
   Main PID: 7228 (dockerd)
      Tasks: 9
     Memory: 25.1M
     CGroup: /system.slice/docker.service
             └─7228 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.545882493+01:00" level=info msg="[graphdriver] using prior storage driver: >
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.551094103+01:00" level=info msg="Loading containers: start."
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.683029078+01:00" level=info msg="Default bridge (docker0) is assigned with >
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.736896742+01:00" level=info msg="Loading containers: done."
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.760438742+01:00" level=warning msg="WARNING: No swap limit support"
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.760505854+01:00" level=info msg="Docker daemon" commit=d7573ab graphdriver=>
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.760604471+01:00" level=info msg="Daemon has completed initialization"
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.784888263+01:00" level=info msg="[core] [Server #7] Server created" module=>
Feb 02 22:30:54 systemd[1]: Started Docker Application Container Engine.
Feb 02 22:30:54 dockerd[7228]: time="2023-02-02T22:30:54.795888318+01:00" level=info msg="API listen on /run/docker.sock"

I did this:

root@vmi414881:/var/run# ln -s /run/docker.sock  docker.sock
root@vmi414881:/var/run# docker ps
root@vmi414881:/run# ls -ls /run/docker.sock
0 srw-rw---- 1 root docker 0 Feb  2 22:30 /run/docker.sock

But now I can’t run it from my devops user (yes, devops is member of docker group):

$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

$ sudo docker ps
rsouza@vmi414881:~$ sudo docker run hello-world

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

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
  3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:
Overview | Docker Documentation

On Ubuntu 20.04 /var/run is a symbolic link to /run so normally /var/run/docker.sock would be the same file as /run/docker.sock.

I moved from contabo to a new provider, but as far as I remember it wasn’t different on their servers. The best way would be if you could make /var/run a symbolic link again to /var/run. Otherwise it is possible that your symbolic link is still owned by root as you created it as root…

Thanks for your reply. Yes, it’s at contabo. Did you know that because vmi ?

I am lost about this issue.

If is already an ln. Why it’s not working here?

The domain name literally contains “contaboserver”. It wasn’T hard to find out :slight_smile:

“ln” is the command not for symbolic links only. I am not sue what you mean. Please, show the output of

ls -l /var | grep run

Since /run and /var/run was different on your vps, it /var/run can’t be a symbolic link, but it should be.

root@vmi414881:~# ls -l /var | grep run
drwx------ 4 root root 4096 Feb 2 23:33 run

This is not a symbolic link.Now how many files do you have in that folder?

ls /var/run | wc  -l
root@vmi414881:~# ls /var/run | wc  -l
root@vmi414881:~# ls /var/run  crond.reboot  dbus  docker  reboot-required  reboot-required.pkgs  unattended-upgrades.lock
root@vmi414881:~# ls

Hello. I followed this post and it seems working.

I am testing a pipeline right now.

Thanks @rimelek

Which post? :slight_smile: Did you forget to share the link?

This one: filesystem - Is my /var directory OK, since /var/run isn’t a symlink? - Ask Ubuntu

my bad!

1 Like