Search code examples
dockerdebianwindows-subsystem-for-linux

Docker in WSL2: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?


I am currently running a Debian Distro (The default one from the Microsoft Store) on WSL 2 and I am having a lot of trouble with running Docker on it. My OS currently is Windows 10 Education Insider Preview, version 2004, and the os build is 19587.1000 and I have Docker Desktop.

Now, at this point, I've literally tried everything. I have tried using the "Expose daemon on tcp://localhost:2375 without TLS" way to no result. Then, I tried enabling "Enable the experimental WSL 2 based engine" (this is also why I had to move to Windows 10 education and get docker desktop and move to this version 2004). I have also commented out "#export DOCKER_HOST=tcp://localhost:2375" from my .bashrc. And then since WSL does not support systemd nor systemctl, starting docker using these are useless, and thus I tried "sudo service docker start" and also "sudo /etc/init.d/docker start". But, still when I run any command in Docker in my WSL, it gives me this:

$ docker ps -a 
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?  

I just can't seem to figure out what is wrong... I've looked up everywhere, tutorials, forums, other questions on StackOverFlow. Most are either about Docker on Native Linux or on WSL 1 where they use the first method of exposing the daemon on tcp://localhost:2375 without TLS which is not very secure, but I didn't even get that working on mine.

Please help! It would be greatly appreciated!! Thanks in advance!


Solution

  • Ok so basically I installed a clean WSL. This time I got a clean Ubuntu, and somehow it fixed the issue. My other WSL distros still won't work with this, but this clean Ubuntu does. However, as soon as I installed some stuff on it, it started breaking again. Now, I reinstalled it and now it works fine. Seems like something could be potentially conflicting with this?