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
- 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
- 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
- Verify if docker is installed
docker --version
docker compose --version
- Create the docker group and add current user to it
sudo groupadd docker
sudo usermod -aG docker $USER
- Update your ubuntu defaults to use iptables
sudo update-alternatives --config iptables
- 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.