Docker on windows wsl not running daemon

536 views Asked by At

I few days ago I installed docker in my WSL version 2 on windows. On Ubuntu

enter image description here

I used the following script provided by this page:

https://nickjanetakis.com/blog/install-docker-in-wsl-2-without-docker-desktop

curl -fsSL https://get.docker.com -o get-docker.sh

The problem is that after installing it, docker seems to be ok, but the docker daemon is not working

enter image description here

As you can see I start the service but if then I check the status it says is not running and also when trying to execute a docker compose or something like that also show the error that the docker daemon is not running

What should I check? I have used docker desktop always but I can not use it now so I have to just use docker in WSL

EDIT: My systemd is enable but I still got an error

enter image description here enter image description here

enter image description here

I also tried to start it manually with

sudo dockerd

but I got this error also enter image description here

Thanks in advance

3

There are 3 answers

0
Gabriel García Garrido On BEST ANSWER

Solved here https://github.com/microsoft/WSL/issues/6655

it was an issue of the iptables, i had to use the legacy ones

3
Antonio Petricca On

Configure systemd by editing the file 'wsl.conf ':

[boot]
systemd=true

Restart wsl...

Then:

sudo systemctl start docker.service

Here more information for systemd for wsl: https://learn.microsoft.com/en-us/windows/wsl/systemd .

3
millerluki On

Follow these steps to use docker in your WSL2 Distro

  1. Check if you have enabled systemd in your WSL2. Open your /etc/wsl.conf and add following line:
[boot]
systemd=true

Restart your WSL2 Distro

wsl --shutdown YOUR_DISTRO
wsl -d YOUR_DISTRO
  1. Install docker

  2. enable the docker daemon with systemd

sudo systemd start docker
  1. check the output of journalctl
journalctl -u docker.service 
  1. Test your installation with
sudo docker run hello-world