Windows + WSL + Docker: Full Setup Without Docker Desktop

Install the Docker engine directly inside WSL 2 on Windows so you get a full Docker CLI without Docker Desktop or a paid licence.

Why skip Docker Desktop

Docker Desktop is the easiest way to run Docker on Windows, but it requires a paid licence for organisations above a certain size and adds a background Windows process. If you already use WSL 2 for development, you can install the Docker engine directly in that Linux environment and get an identical CLI experience for free.

Enable WSL 2

Open PowerShell as an administrator and run:

wsl --install
wsl --set-default-version 2

Restart when prompted. Then install Ubuntu from the Microsoft Store or with:

wsl --install -d Ubuntu

Verify the version after the install completes:

wsl -l -v

You should see VERSION 2 next to your distro name.

Install Docker engine inside WSL

Open your WSL terminal (Ubuntu) and run the official install script:

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
  | sudo tee /etc/apt/sources.list.d/docker.list

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

Start the daemon and run a test

Start the Docker daemon and run the hello-world container:

sudo service docker start
docker run hello-world

If you see the hello-world output, the engine is working.

Remove the need for sudo

Add your user to the docker group so you do not need sudo for every command:

sudo usermod -aG docker $USER

Close and reopen your WSL terminal for the group change to take effect.

Fix the socket path (optional)

If the CLI cannot find the daemon, add this to your ~/.bashrc or ~/.zshrc:

export DOCKER_HOST=unix:///var/run/docker.sock

Reload the profile with source ~/.bashrc.

Start Docker automatically with WSL

WSL does not run systemd by default on older Ubuntu versions. The cleanest workaround is to add the start command to your profile:

# ~/.bashrc
if [ "$(service docker status 2>&1 | grep -c 'not running')" -gt 0 ]; then
  sudo service docker start > /dev/null 2>&1
fi
Alternatively, enable systemd in WSL 2 by adding [boot] systemd=true to /etc/wsl.conf and restarting WSL. With systemd, Docker starts automatically on every WSL session.