Stolen from here https://www.codingwithcalvin.net/installing-docker-and-docker-compose-in-wsl2ubuntu-on-windows/
To get started, I’m running Windows 10 and have WSL2 installed running Ubuntu. Even more specifically:



This likely works across multiple versions of each of these items, but just want you to know up front :).
Okay, so how do we get this working? Here we go.
First, open an instance of WSL2, because we need to type a number of commands.
If you’ve ever had Docker installed inside of WSL2 before, and is now potentially an “old” version – remove it:
Shell
1
sudo apt-get remove docker docker-engine docker.io containerd runc
Now, let’s update apt so we can get the current goodies:
Shell
1
sudo apt-get update
2
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
Once that’s finished, let’s add the official GPG key for Docker:
Shell
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Now, let’s add the stable repository to apt:
Shell
1
echo \
2
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
3
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now we can actually install Docker! Run the following commands:
Shell
1
sudo apt-get update
2
sudo apt-get install docker-ce docker-ce-cli containerd.io
Docker is now installed! Yay! And I’m dumb, so I thought that was all, so I navigated to my source code directory and ran –
Shell
1
docker-compose up
The error messages following that made me realize that I still need to install docker-compose, so here we go!
Since we’ve got everything updated and looking good, this part is just a single command –
Shell
1
sudo apt-get install docker-compose