Sunimal Herath

Automation, Scalability, and Reliability – DevOps Unleashed.

Installing Docker Engine on Ubuntu (WSL2)

I’m running Ubuntu on WSL2 and was looking to install docker in it. I found this article, “Docker Desktop WSL 2 backend on Windows“, but it is for installing docker on Windows and use WSL2 as the back end.

What I wanted is to install Docker on Ubuntu running on WSL2. So, I followed the article “Install Docker Engine on Ubuntu” and it worked.

The default user in Ubuntu (WSL2) does not have the permission to run any docker commands, so, it’s better to add user to the “docker” group like below, otherwise, you need to execute every Docker commands with sudo.

usermod -aG1 docker2 <username>

newgrp3 <username>

  1. -a for append, -G for groups. ↩︎
  2. docker – name of the group. ↩︎
  3. This changes the user’s group to the group specified in the -G. ↩︎