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) `
To start Docker in daemon mode, choose Application > Start "Docker Daemon". The state should transition to "Running" after a few seconds and Docker Daemon should be accessible over the remote bridge. That's it! Next time your computer boots, Docker Daemon will start up immediately, before anyone logs on.
Windows Subsystem for Linux 2 sports an actual Linux kernel, supporting real Linux containers and Docker. Docker works on WSL 2, and without requiring the robust but heavy Docker Desktop if that is undesirable.
From the Docker menu, select Settings > General. Select the Use WSL 2 based engine check box. If you have installed Docker Desktop on a system that supports WSL 2, this option will be enabled by default. Click Apply & Restart. Ensure the distribution runs in WSL 2 mode.
Open the ~/.profile (or ~/.zprofile if you are using ZSH rather than Bash) in your WSL distribution, and add a section like so to it: This piece of code will run every time you open a new shell on your WSL distribution. It checks whether the Docker Daemon is running, and if not, starts it without prompting for credentials.
Once installed, start Docker Desktop from the Windows Start menu, then select the Docker icon from the hidden icons menu of your taskbar. Right-click the icon to display the Docker commands menu and select "Settings". Ensure that "Use the WSL 2 based engine" is checked in Settings > General.
By enabling the WSL 2 based engine, you can run both Linux and Windows containers in Docker Desktop on the same machine. Docker is a tool used to create, deploy, and run applications using containers.
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
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
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.
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.
By default the wsl is version 1 (wsl 1) and docker required wsl2.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With