DEV Community

jgngo
jgngo

Posted on

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

Top comments (0)