Install Docker Community in WSL 2 (Ubuntu 22.04)

jgngo

jgngo

Posted on April 25, 2022

Install Docker Community in WSL 2 (Ubuntu 22.04)

After installing Ubuntu 22.04 stable in WSL, I proceeded to install Docker Engine using the official Docker instructions. Since this is WSL, running sudo systemctl start docker does not work. To start the docker service, you'll need to use sudo /etc/init.d/docker start.

You will notice that the docker service is not running if you check using sudo /etc/init.d/docker status. The reason is because of this error in starting docker.

To fix this, you will need to update your default iptables to the legacy option. After doing this, you should be able to start the docker service and run the normal docker commands.

$ sudo update-alternatives --config iptables

There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode
  1            /usr/sbin/iptables-legacy   10        manual mode
  2            /usr/sbin/iptables-nft      20        manual mode
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
jgngo
jgngo

Posted on April 25, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Optimize Huge Virtual Hard Disk.
docker Optimize Huge Virtual Hard Disk.

September 16, 2024

Docker GPU no Windows com WSL2
containers Docker GPU no Windows com WSL2

February 17, 2024