Wsl2 Install Docker

Docker have recently announced changes to their pricing and subscriptions which require a paid subscription for users outside of personal, education and small business use.

Wsl2

It seems that this license change only applies to Docker Desktop which is the GUI client for Windows and Mac. The good news is that you can install the Docker Engine on Windows using Windows Subsystem for Linux 2! The bad news is that you won’t have easy access to the GUI to manage containers; you’ll have to use the CLI (although I prefer this anyway).

Install

Install WSL2 (and Ubuntu)

Wsl2 Install Docker-compose

The first step if you haven’t done it already is to get WSL2 install. I’d recommend setting up WSL2 by following the Microsoft guide to install WSL2 on Windows 10.

Script: you are new to Docker and containers, this video will hel. Step 6: Install latest Docker version. Sudo apt-get install docker-ce. This step completes Docker Installation on your WSL2, now you have to do a quick rain check. Step 7: Check Docker Version To check whether docker is installed properly or not check Docker version using this command docker -version.

I installed the Ubuntu distribution since this is what I am most familiar with.

InstallWsl2

After WSL2 is setup, you can install Ubuntu by running the following command.

Wsl2 install docker

Install Docker Engine on WSL2

Now that we have Ubuntu setup on WSL2 we can install the Docker Engine. Docker have a guide for installing Docker Engine on Ubuntu, I would recommend using the repository installation method since this will make installing updates much easier in the future.

After Docker Engine has been installed, I would also recommend following the post-installation steps for Linux. This will allow you to execute Docker commands without requiring to be a root user and ensure that Docker Engine starts on boot.

Wsl2 Install Docker Cli

Steps I followed

For simplicity, I ran the following commands on Ubuntu 20.04 to setup Docker Engine on my machine.

Wsl2 Ubuntu 20.04 Install Docker

Run Docker Commands

At this point you should have a fully operation Docker Engine installed running on Ubuntu under WSL2. You can check this by trying to run the hello-world image from Docker Hub.

After this has completed you should see a message from docker indicating it was successful. If you’re seeing that message, you are ready to go!

One drawback of this approach is that you will need to start the docker service yourself after rebooting or restarting WSL2. You can do this by running the following command.

Summary

With the steps above you should have a working copy of Docker Engine running with WSL2! Enjoy!

Wsl2 Install Docker Ubuntu

If your copy isn’t running you might want to check the following things.

  • Ensure your WSL distribution is running on WSL2. You can check by running wsl –l –v.
  • Make sure the docker service is running. You can start the service by running sudo service docker start.