2

I'm trying to run docker in WSL (Windows 10) using the command sudo service docker start, and it shows:

 Starting Docker: docker

but when I run sudo docker images, it tells me:

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

Any ideas on how I can fix this?

10
  • Hello. So to be clear you will have Windows 10 with WSL running on top of that and now you want Docker running on top of WSL? I have to ask why?
    – David
    Apr 13, 2022 at 11:33
  • Because I have some aws Credential access that did not work on windows
    – Yafaa
    Apr 13, 2022 at 11:36
  • Sorry that does not explain why you are not running the Docker on windows instead of building this tower. Docker is a container what will be running in it?
    – David
    Apr 13, 2022 at 11:38
  • Hello and welcome to Ask Ubuntu. What Ubuntu release are you using on WSL, and can you provide more detail on how you installed it and Docker? Thanks! Apr 13, 2022 at 14:37
  • It also might be useful to include the output of ps n -efH to see if the daemon is still running. Apr 13, 2022 at 14:42

2 Answers 2

7

It comes from nftables used instead of iptables
I found this solution
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
from these threads:
https://github.com/microsoft/WSL/discussions/4872
https://patrickwu.space/2021/03/09/wsl-solution-to-native-docker-daemon-not-starting/

1
  • Just a heads-up for readers that this is specific to Ubuntu 22.04 (really, I believe 20.10) with WSL. The OP never responded on which version they were using, but most readers who find this will experience this on Docker Engine with Ubuntu 22.04 specifically. Oct 28, 2022 at 18:00
1

I had this problem after a power outage. If it's the same problem that happened to me, then maybe your settings.json for Docker has been corrupted. To fix:

  • Move %AppData\Docker\settings.json (typically C:\Users\<user_user_profile>\AppData\Roaming\Docker\settings.json) to a safe location for backup
  • Restart Docker Desktop
  • If this corrects the issue for you, you can delete the backed-up settings.json. If not, you can restore it to the previous location.
2
  • Good info - Thanks! Note, however, that most users that have this error are experiencing it due to the iptables issue mentioned in the other answer, so I would personally recommend that they try that first. However, this is a great "second step" if that doesn't work. Also, the iptables issue will likely go away over the long-term, as the WSL2 kernel supports nftables. So it's definitely nice to have an alternative cause to look at! Oct 28, 2022 at 17:57
  • Also just realized that this question was specific to Docker Engine, whereas your answer is for Docker Desktop. But that's still useful/helpful info for users of Docker Desktop, IMHO. Oct 28, 2022 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .