Developer & Gamer

Follow me on GitHub
Home | Blog | Projects | Ideas | About me

Running docker engine inside WSL2



Installing MS Store version of WSL2

Even if you’ve installed WSL2 before using one of the distributions listed in the Microsoft Store, there is a separate Store Product by Microsoft called Windows Subsystem for Linux that supports a crucial feature, called initd.

Go ahead and install that package. If you have existing distributions, they will be kept. The installation of this store product will only update WSL2 itself, and won’t mess with your distributions.

You can also install the package using WinGet within PowerShell:

winget install 9P9TQF7MRM4R --source msstore

You can check your install by running wsl --version in PowerShell or Cmd. The expected output should be similar to this:

WSL version:
Kernel version:
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version:
Windows version: 10.0.22631.3007

Installing Ubuntu distro

Similar steps might work in other distros as well, but I have verified these steps only for the Ubuntu distro, so that’s what this tutorial will be focused on.

In powershell, run the following to install a new Ubuntu instance:

wsl --install -d Ubuntu-22.04

This command should land you in the account creation. Create your local account for the distro. After that you should be greeted with the MOTD and a bash. Go ahead and update all packages:

sudo apt-get update & sudo apt-get upgrade -y

Verify systemd

While still in bash inside the WSL2 Ubuntu instance, run:

cat /etc/wsl.conf

This should output


If the file does not exist or contains something else, refer to these steps.

Install docker

Inside the Ubuntu bash, execute:

sudo bash -c 'apt-get install -y apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL | apt-key add - && \
add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable" && \
apt-get update -y && apt-get install -y docker-ce && usermod -aG docker $USER && newgrp docker && exit'

Use docker

sudo docker run hello-world

Done! You can now use Docker inside your WSL2 Ubuntu 22.04!

Details & Troubleshooting

Checking Windows Version

  1. Open the “Run” prompt of Windows by pressing Win + R
  2. Type in “winver” into the prompt and submit the command
  3. A window should open

Checking virtualization

  1. Open Task Manager
  2. Navigate to the performance “tab”
  3. Navigate to the CPU details
  4. The details should display “Virtualization: Enabled”

Configuring systemd inside WSL

Replace /etc/wsl.conf inside the distro with the following:


In Windows, use PowerShell to power-cycle the distro:

wsl --shutdown
wsl -d Ubuntu-22.04