14

I have recently installed WSL2 and installed Ubuntu from Microsoft Store.When i run docker using

Sudo service docker start, i get below message

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

I followed steps as per this Answer and did below

    sudo groupadd docker
sudo usermod -aG docker $(whoami)

But still cant start docker..when checking Docker logs, i could see below

CONNECTING" module=grpc Error starting 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) `

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94

4 Answers4

34

I have tried a lot of steps based on the error below

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) `

But Starting Terminal as administrator worked.Even though you run

sudo service docker start

The Terminal should be launched as Admin

Victor Alves
  • 7,306
  • 1
  • 13
  • 15
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
  • 4
    OMG I can't believe this was my problem – user1099123 Jan 20 '20 at 02:57
  • 1
    So simple... Thanks! – Dikla Mar 18 '20 at 13:28
  • 1
    Launching PowerShell as Administrator solved the problem for me!! So much thanks – FonzTech Oct 21 '20 at 12:14
  • 1
    If anyone is getting "CHAIN_ADD failed (No such file or directory): chain PREROUTING" because you are using Debian, refer to this: https://forums.docker.com/t/failing-to-start-dockerd-failed-to-create-nat-chain-docker/78269/2 – Himbeer Oct 30 '20 at 18:01
  • 1
    Was struggling with this for the past two days, the docker was running, but the hello-world did not! This simple yet effective trick worked wonders! Thanks a lot! :-) – robot_alien Jun 26 '22 at 16:40
11
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

from https://forums.docker.com/t/failing-to-start-dockerd-failed-to-create-nat-chain-docker/78269

Spithas
  • 161
  • 1
  • 6
4

I might be late but I faced similar problem and the solution was completely different.
I am posting here for someone if he/she gets similar issue.

Problem I Faced.

I setup wsl and docker in my new machine. I can not run dockerd in wsl2. As TheGameiswar suggest I can start the dockerd if I run the terminal as Admin but I still can not run any image.

The root cause

By default the wsl is version 1 (wsl 1) and docker required wsl2.

Solution

Set the default wsl version to 2

wsl --set-default-version 2

set the installed distro to wsl2

wsl --set-version  Ubuntu-20.04 2
er.bhargav.vyas
  • 301
  • 2
  • 6
  • Can confirm - I followed a variety of guides online, and even after ensuring I *upgraded* to WSL 2 - bizarrely the need to SET the system to USE WSL2 was another, opaque, step. – Gavin C Aug 27 '22 at 09:51
0

There is a great guide here which gives some up to date instructions and some prerequisites on using WSL 2 and the new docker desktop.

Damo
  • 5,698
  • 3
  • 37
  • 55