Install Docker Wsl2 Ubuntu

Docker with WSL2 allows you to run linux containers on windows as it can be installed in WSL for windows directly. When you are building your application, you can use linux images in your dockerfile whereas if you were installing it without WSL2 then you were limited to using only windows based images as it was installed on windows kernel. Install Windows Subsystem for Linux with the command, wsl -install. Use a Bash terminal on your Windows machine run by your preferred Linux distribution - Ubuntu, Debian, SUSE, Kali, Fedora, Pengwin, Alpine, and more are available.

Docker Desktop just announced/released their new subscription model, and it hasn’t sat well with many folks. The good news is there are ways around it, even 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:

Now, let’s update apt so we can get the current goodies:

Once thats finished, let’s add the official GPG key for Docker:

Now, let’s add the stable repository to apt:

Now we can actually install Docker! Run the following commands:

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

The error messages following that made me realize that I still need to install docker-compose, so here we go!

Install Docker Wsl2 Ubuntu Windows 10

Since we’ve got everything updated and looking good, this part is just a single command:

Install Docker Wsl2 Ubuntu Windows 7

Now, some caveats:

Docker isn’t always running by default when you launch WSL2. You can likely add it as a service to autostart, but I haven’t done that (yet). For nowI just run the following command with every new session:


The version in my docker-compose.yml file was higher (because of Docker Desktop) than what is allowed with the current version of docker-composewithin WSL2. I wasn’t using anything special, so I was able to simply “downgrade” the version in the compose file without issue.

Install Docker Wsl2 Ubuntu Free

My containers are coming from our private registery in AWS ECR. Because of that, I also had to install the AWS CLI tools and get that authenticationworking before docker-compose would actually start up given my compose file. If you’re interested, those commands are:

Install Docker Wsl2 Ubuntu Latest

Once I did that, everything was good to go, and I was able to uninstall Docker Desktop.

Install Docker Wsl2 Ubuntu 20.04

Good luck, readers!

Install Docker Wsl2 Ubuntu

This post, “Installing Docker, and Docker-Compose, in WSL2/Ubuntu on Windows”, first appeared on