'Issue in running docker on WSL2 Ubuntu 18 LTS

I have ubunto 18 LTS wsl2 on my windows 10 machine.

have installed the docker - please find below screenshot Docker Version and Starting service

Now after starting the Docker service, I tried checking the docker info however encountered below error.

Error while trying info

I did some research and came across this post - Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?

as suggested in this, systemctl start docker also tried however got error as System has not been booted with systemd as init system (PID 1). Can't operate.

one more suggestion was to try out sudo dockerd - this resulted into below logs

INFO[2020-07-21T14:45:02.918374600+05:30] [graphdriver] using prior storage driver: overlay2
WARN[2020-07-21T14:45:03.044702300+05:30] Your kernel does not support cgroup memory limit
WARN[2020-07-21T14:45:03.046625300+05:30] Unable to find cpu cgroup in mounts
WARN[2020-07-21T14:45:03.049054700+05:30] Unable to find blkio cgroup in mounts
WARN[2020-07-21T14:45:03.051115500+05:30] Unable to find cpuset cgroup in mounts
WARN[2020-07-21T14:45:03.053056000+05:30] mountpoint for pids not found
INFO[2020-07-21T14:45:03.056254900+05:30] Loading containers: start.
WARN[2020-07-21T14:45:03.108913100+05:30] Running iptables --wait -t nat -L -n failed with message: `iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.`, error: exit status 3
INFO[2020-07-21T14:45:03.522988800+05:30] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2020-07-21T14:45:03.523923200+05:30] stopping healthcheck following graceful shutdown  module=libcontainerd
INFO[2020-07-21T14:45:03.524034200+05:30] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3) 

sudo dockerd logs

Moving on I googled above issue of iptable and found https://stackoverflow.com/questions/21983554 as instructed in forum , i tried sudo modprobe ip_tables which gave modprobe: FATAL: Module ip_tables not found in directory /lib/modules/4.4.0-18362-Microsoft

After all this I need some guidance if i am on right track.



Solution 1:[1]

Running WSL2 Ubuntu as administrator from Windows solved this issue for me. Thanks to celinhoBruxo comment here

EDIT:

My issue was actually coming from that I tried to install directly WSL2 Ubuntu from Windows Store on a Windows version which doesn't support that (Version 1909). I followed this page before installing again and everything worked fine without needing to run Ubuntu as admin from Windows.

Solution 2:[2]

1.kill dockerd process (if no processes are found go to 2) ps -aux | grep dockerd

kill -9 DOCKERD_PROCESS_ID

2.sudo dockerd &

Run dockerd successfully!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Balha