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!
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.
This was very helpful to solve my problem although mine was slightly different. I initially installed the engine, then after installing docker-desktop I could not connect to the daemon with either sudo or my user. I had to uninstall desktop (other problems still debugging) and still couldnât run the commands with sudo until I discovered this post. My âdefaultâ context points to the proper socket. After using âsudo docker context use defaultâ I could run the commands as root. The desktop-linux context was a stale context that is no longer valid after purging desktop.
Which is true as nobody used unix:// in a symlink command. You wouldnât try to use http:// either. I also donât see why creating a symlink would be necessary. You change context and you are done. Symlink could only be necessary if you want multiple contexts using the same socket.
Thanks for the reply. I got this now. It was actually an issue with the Intellij Idea IDE which wasnât picking the default context. This got resolved once I switched back to desktop-linux as default builder in docker desktop