Before we begin

This guide only applies if we will not be using Docker Desktop on Windows (which I really do not recommend because of the I/O latency).

Requirements

Make sure you have all the stuff needed for this setup:

  • A computer that supports virtualization
  • Windows 11
  • WSL 2

Here are the steps

  1. Clean up existing docker installation (if there is any)
sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc
  1. Download and run the official docker installer script (be sure to verify the file you download before running them).
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
  1. Verify if docker is installed
docker --version
docker compose --version
  1. Create the docker group and add current user to it
sudo groupadd docker
sudo usermod -aG docker $USER
  1. Update your ubuntu defaults to use iptables
sudo update-alternatives --config iptables
  1. Restart WSL. Open a Powershell and run the following command:
wsl --shutdown
wsl 

Final steps

Now that we got docker installed, try running the following command:

docker run hello-world

We should see a text that says the installation is working correctly.