Yet Another "Cannot connect to the Docker daemon" Post

Commands like docker ps return the following error:

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

I am using Docker CE version 28.1.1

The issue started after after updating all packages on my Debian system. Before the update, Docker was running just fine.

docker context ls returns only one context: the “default” context.

docker context inspect --format '{{ .Endpoints.docker.Host }}'

returns

unix:///var/run/docker.sock

The socket file “/var/run/docker.sock” exists and my user does have the permission to access it.

There is no “DOCKER_HOST” environment variable.

sudo systemctl status docker

shows that the docker daemon is indeed running. But

sudo journalctl -u docker

shows that some warnings were logged while starting the daemon.

Apr 18 19:55:47 [redacted] systemd[1]: Starting docker.service - Docker Application Container Engine...
Apr 18 19:55:47 [redacted] dockerd[51720]: time="2025-04-18T19:55:47.632810981-06:00" level=info msg="Starting up"
Apr 18 19:55:47 [redacted] dockerd[51720]: time="2025-04-18T19:55:47.633434704-06:00" level=info msg="OTEL tracing is not configured, using no-op tracer provider"
Apr 18 19:55:47 [redacted] dockerd[51720]: time="2025-04-18T19:55:47.644583850-06:00" level=info msg="Creating a containerd client" address=/run/containerd/containerd.sock timeout=1m0s
Apr 18 19:55:47 [redacted] dockerd[51720]: time="2025-04-18T19:55:47.655856774-06:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Apr 18 19:55:47 [redacted] dockerd[51720]: time="2025-04-18T19:55:47.659264701-06:00" level=info msg="Loading containers: start."
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.807557075-06:00" level=warning msg="Error (Unable to complete atomic operation, key modified) deleting object [endpoint_count db16e770164bb1073117e2387b88ab1372fe2d664e677e98ff25d6300e77e634], retrying...."
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.876990194-06:00" level=warning msg="error locating sandbox id 6774f13a7241ea45359f81f15d441b9643896a4b144d476b6eb2ebc1500e7bf1: sandbox 6774f13a7241ea45359f81f15d441b9643896a4b144d476b6eb2ebc1500e7bf1 not found"
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.877020365-06:00" level=warning msg="error locating sandbox id d6352ad64da70e7e9ec29b873e90a26478e6e1bf5715b69ddf42548a8852db1e: sandbox d6352ad64da70e7e9ec29b873e90a26478e6e1bf5715b69ddf42548a8852db1e not found"
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.877191155-06:00" level=info msg="Loading containers: done."
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.887183789-06:00" level=info msg="Docker daemon" commit=01f442b containerd-snapshotter=false storage-driver=overlay2 version=28.1.1
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.887243488-06:00" level=info msg="Initializing buildkit"
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.908866379-06:00" level=info msg="Completed buildkit initialization"
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.911973455-06:00" level=info msg="Daemon has completed initialization"
Apr 18 19:55:48 [redacted] dockerd[51720]: time="2025-04-18T19:55:48.912029997-06:00" level=info msg="API listen on /run/docker.sock"
Apr 18 19:55:48 [redacted] systemd[1]: Started docker.service - Docker Application Container Engine.

Any guidance on how to find the reason for this error will be very much appreciated!

I figured it out! Somehow running sudo apt upgrade caused the Docker Snap package to be installed. I never installed the Snap package manually! And this Snap package caused my other Docker that was installed using apt to stop working.

Fixed the problem by running sudo snap remove docker --purge then restarting my computer.

2 Likes

That’s really bad and unexpected. Thank you for sharing the solution. I’m surprised that a snap version upgrade installs their own Docker package. Is there any chance that the snap package was originally installed automatically which you later disabled and it was just enabled again?

For sure I never did anything related to the Docker Snap before. I never installed it or disabled it manually.

I am starting to think that maybe it was not the apt upgrade that caused the Docker Snap to be installed. Maybe it was a Snap package auto-update. Maybe another Snap package added the Docker Snap as a dependency and installed it as part of an auto-update that I did not initiate manually.

The only Snap package I currently have installed on this computer is storage-explorer. Their latest release notes mention some new Docker-related features. Which makes me think that maybe they added a dependency on the Docker Snap and caused this whole issue.

I have little understanding of the Snap package manager, how it handles dependencies, and how it handles updates. But it is really bad that it silently installed the Docker Snap on my computer.