Reason:
If Docker was installed as a snap package (docker.snap), it may have conflicted with another non-snap Docker installation or caused permission issues.
Snap manages applications in isolated environments, which can restrict access to system resources like docker.sock.
Also Snap automatically updates its packages. If it updated Docker during an active session, it could have restarted or stopped the Docker daemon, leading to:
“Cannot connect to the Docker daemon at unix:///var/run/docker.sock.”
Solution:
- First, Verify whether Docker was installed via snap or another method.
- remove the snap version to avoid conflicts if it is installed via snap.
- Use the following documentation to install the docker or you can use the docker desktop GUI application:
How To Install and Use Docker on Ubuntu 20.04 | DigitalOcean