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

I followed the instructions Ubuntu | Docker Docs on a new virtual machine.
Next in step 3 Part 1: Containerize an application | Docker Docs after running the command
docker build -t getting-started .
an error is issued
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Information about the environment:
Ubuntu 22.04
avauser@web:~/getting-started-app$ docker compose version
Docker Compose version v2.23.0-desktop.1
avauser@web:~/getting-started-app$ docker --version
Docker version 24.0.7, build afdd53b
avauser@web:~/getting-started-app$ docker version
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Client: Docker Engine - Community
Cloud integration: v1.0.35+desktop.5
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:07:41 2023
OS/Arch: linux/amd64
Context: default

Similar topics are not suitable for these reasons:

1. https://forums.docker.com/t/error-cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker-daemon-running/115408
Not suitable, since Docker Engine is considered there
2. https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker-daemon-running/130002
Not suitable, since Docker Engine is considered there
3. https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker-daemon-running/57372
Not suitable, since it runs under Windows
4. https://forums.docker.com/t/docker-cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker-daemon-running/79657
Not suitable, as it runs under DockerHub
5. https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker-daemon-running-2-0/64828/5
Not suitable, since docker-compose was installed

Hi. This is an English community forum, please, edit your post and translate the non-English parts of your message to English, otherwise your post could be removed. Thank you!

Hi!
It was translated.

If you are using the Desktop, the context shouldn’t be default but “desktop-linux”. It could also be default, but if you installed docker engine as well, and you don’t have the docker group and don’t use sudo, you can’t access the docker socket.

Try

docker context use desktop-linux

and try docker commands again.

Many people misunderstood the installation guide and installed the engine as well, not just the client. Docker Desktop needs only the client.

1 Like

I had the same issue with the same configuration. I’ve solved this in this manner:

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

  • Step 1. Verify context, it should be dektop-linux
    $ docker context show
  • Step 2. Change the context if needed
    $ docker context use desktop-linux
  • Step 3. Find the docker.sock file location
    $ docker context ls
  • Step 4. Create symlink
    $ sudo ln -s /home/<user>/.docker/desktop/docker.sock /var/run/docker.sock
2 Likes

thank you so much for this!
the error was solved on my machine.