Skip to content

Installing Docker in WSL

Remove any old Docker installs

In WSL run the following command in the terminal:

sudo apt remove docker docker-engine docker.io containerd runc

WSL v0.67.6+ (Currently in Pre-release)

Can be manually installed via: - https://github.com/microsoft/WSL/releases/download/0.67.6/Microsoft.WSL_0.67.6.0_x64_ARM64.msixbundle

Install the prerequisites

In WSL run the following command in the terminal:

sudo apt-get update

sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Configure the package repository

In WSL run the following command in the terminal:

sudo mkdir -p /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 > /dev/null

Install Docker

In WSL run the following command in the terminal:

sudo apt-get update

# If you get a GPG error when running the above command you can run the following command, otherwise don't run it. 
sudo chmod a+r /etc/apt/keyrings/docker.gpg

sudo apt-get install docker-ce docker-ce-cli containerd.io

Start Docker

In WSL run the following command in the terminal:

sudo service docker start

Setup permissions

In WSL run the following command in the terminal:

sudo groupadd docker

sudo usermod -aG docker $USER

Logout of Linux and log back in. Then run the following command in the terminal in WSL:

newgrp docker

# Verify the commands worked and it can run without sudo.
docker run hello-world

Configure Docker to start on boot

In WSL run the following command in the terminal:

sudo systemctl enable docker.service

sudo systemctl enable containerd.service

Installing docker-compose

In WSL run the following command in the terminal:

# The specified version can be configured to any available version 
sudo curl -L "[https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname](https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname) -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# Makes the binary executable
sudo chmod +x /usr/local/bin/docker-compose

You can now use Docker Compose with docker-compose in the terminal.