Skip to main content
Before installing Docker Engine on WSL, make sure you have WSL installed and running. If not, follow the Mastering WSL guide first.
1
Set up Docker’s apt repository
2
The main reason to set up Docker’s apt repository is to ensure you’re installing the latest version of Docker Engine on WSL. By default, the apt repository only contains the stable version, which may not be the latest.
3
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
4
Install the Docker packages
5
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
6
By default, the Docker service will start automatically after installation. Verify it with:
7
sudo systemctl status docker
8
If it is disabled, enable it by running:
9
sudo systemctl enable docker
sudo systemctl start docker
10
Verify the installation
11
sudo docker run hello-world
13
Refer to the Docker post-install docs for more details.
14
By default, you need sudo access to run Docker commands. To avoid this, add the current user to the docker group.
15
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

# Check the access
docker run hello-world

Build docs developers (and LLMs) love