Cannot connect to docker daemon at unix

I have just started my learning in docker. I have install docker in my old pc running Ubuntu desktop. I am accessing it through ssh. Whenever I try cmds like “docker ps”, it returns error like “Cannot connect to the Docker daemon at unix:///home/user/.docker/desktop/docker.sock. Is the docker daemon running?”, but the docker is running when checked the status. I have tried almost all the methods that I have found in the Google. Kindly help me through this issue.

Here is it explains it well

Cannot connect to docker daemon

@dataheadless can you share how your blog post helps with rootless docker or Docker Desktop for Linux? The path of the docker.sock does not indicate that (rootfull) docker-ce is used or Docker Desktop for MacOS, which is what your blog post covers.

Links to own blog posts are welcome, as long as they match the subject. Your last link does not!

Thanks for the solution. I just got the solution, by simply running the commands by sudo solves it. I hope in future I can simply the solution.

There must be more to it…

Can you share the outputs of:

dpkg -l | grep docker
snap list docker
docker context ls
sudo docker context ls

I am surprised you manged to install docker, without noticing that sudo is required to use the docker-cli, as it’s written in the installation documentation:

Furthermore, you might want to look at the post-installation steps. Though, first we should clarify whether a docker double installation exist.

Please, share what methods you tried so we don’t spend time on ideas that didn’t work.

How did you check it?

Make sure you don’t have Docker Engine and Docker Desktop installed on the same machine. You can do that intentionally if you know what you are doing, but it isn’t necessary and it confuses most of the people.

And finally, do you really need Docker Desktop on a machine which you connect to using SSH?

1 Like

there is section covered for linux as well

Just out of curiousity: does the path to the docker.sock looks like docker-ce is used?