DEV Community

Cover image for Get Started with Docker - Part 2b: Windows 11 Install Guide (WSL and Docker Desktop Edition)
Repro Dev
Repro Dev

Posted on • Originally published at reprodev.com

Get Started with Docker - Part 2b: Windows 11 Install Guide (WSL and Docker Desktop Edition)

Running Docker on Windows can be a bit trickier than on Linux but on the flipside can be easier to maintain.

Docker on Windows was mine and many other people’s first step into the Docker ecosystem.

In this guide, we'll install Docker onto a Windows 11 machine using Docker Desktop and WSL2 (Windows Subsystem for Linux).

We’re going to:

  • Install WSL (Windows Subsystem for Linux) and the default Ubuntu distribution using Windows PowerShell
  • Update WSL1 to WSL2 (if on Windows 10)
  • Install Docker and all it’s required components like Docker Compose using Docker Desktop for Windows
  • Download a Docker Image and run a test Docker Container using the WSL Shell

💡 If you're looking to get this installed on Linux especially the Raspberry Pi then check out our *"Get Started with Docker - Part 2a : Raspberry Pi Install Guide"*


What’s WSL?

The Windows Subsystem for Linux (WSL) is a full Linux distribution that runs underneath the Windows 10 and 11 operating system. Once installed you can log into a WSL shell using your terminal and send Linux commands like you were using a Linux machine. Machines like a Raspberry Pi.

Pimp My Windows OS Xzibit Meme

The real advantage to this is that you don’t need to use another application like VMWare Workstation to spin up a Linux Virtual Machine. It's also a great way to learn Linux command line.

You can get more information on WSL in general from the official Microsoft Learn article linked below if you want to learn more.

Install WSL with Microsoft Learn

You can run Docker on Windows without installing WSL by using Hyper-V for Virtualization. However, you’ll get much better performance and compatibility overall if you use the WSL2 backend.

❓ Please Note: If your machine currently has Hyper-V installed and enabled then be aware this guide will switch off Hyper-V


Install WSL

We’re going to use Windows PowerShell to get this installed in just one command

  • Click the Start Menu and type ‘powershell' to find the app in the list
  • Left click “Run as administrator” in the right hand menu to open this up as Administrator

WSL Install 01

  • Click Yes on the User Account Control notification to continue

WSL Install 02

  • Click Yes on the User Account Control notification to open PowerShell

WSL Install 03

  • You now have a Windows PowerShell command prompt running as an Administrator

WSL Install 04

  • Type the below command and Press Enter to start the install
wsl --install
Enter fullscreen mode Exit fullscreen mode

WSL Install 05

  • This command will enable a few optional Windows features automatically
  • First up, it will install and enable the Virtual Machine Platform

WSL Install 06

WSL Install 07

  • Then it will install and enable the Windows Subsystem for Linux

WSL Install 08

  • Finally, it'll install and download the Default Linux distribution provided by Microsoft for WSL
  • The Default distribution at time of writing is Ubuntu 22.04.01 LTS

WSL Install 09

WSL Install 10

  • Restart your machine from the Start Menu to complete the install

WSL Install 11

  • You’ll get a screen saying saying “Configuring Windows” or “Adding Features".
  • Once rebooted, go ahead and log back in to Windows to continue the installation.
  • Wait a few minutes and a command prompt window will pop up up like below with a title e.g. Ubuntu.

WSL Install 12

  • This will launch Ubuntu for the first time.
  • You'll need to set a Username and password for your WSL installation.

💡 This can be different from your *Windows* *username* as they are not connected but there's no issue if they are the same.

  • In this example, we'll set the UNIX username as reprodev
  • Type your username and Press Enter to continue

WSL Install 13

  • Set a New password and Press Enter

WSL Install 14

  • Retype the New password to confirm

WSL Install 15

  • Press Enter and as long as the passwords match, then it'll be updated
  • You'll get a message with "Installation successful!" to wrap up the Ubuntu setup in WSL

WSL Install 16

  • After a minute or so you'll be taken to the Ubuntu command line

WSL Install 17

  • We'll be getting more familiar with this soon but for now type the below command to exit and Press Enter to close this window
exit
Enter fullscreen mode Exit fullscreen mode

WSL Install 18


Check and Test the WSL Installation

Before we get onto the Docker Desktop installation we need to take a moment to check that WSL and Ubuntu have installed correctly.

  • Open up Windows PowerShell again as an Administrator

WSL Install 19

  • Type the below command to confirm that WSL has been installed correctly
wsl --status
Enter fullscreen mode Exit fullscreen mode

WSL Install 20

  • You should see the Default Distribution as Ubuntu and the Default Version 2 for WSL

WSL Install 21

Congratulations, we're halfway there. We’ve installed Linux on Windows using Windows PowerShell on Windows 11.


Update WSL1 to WSL2 (For Windows 10)

The latest version of Windows Subsystem for Linux is WSL2, if you don’t update now you’ll get an error when starting Docker Desktop later on.

💡 If you're using Windows 11, then you can skip ahead to the next section to install Docker Desktop as you'll have WSL2 set as default. 

If you're using Windows 10 then you may have to update your WSL version manually.

  • Type the below command and run as an Administrator in Windows PowerShell
  • Press Enter to start the update.
wsl --update
Enter fullscreen mode Exit fullscreen mode
  • Once completed you'll need to reboot and then you can install Docker Desktop

Install Docker on Windows with Docker Desktop

Now that we've installed WSL2 on Windows, we can get started on the Docker part of this installation and get those containers running.

  • Open a Web Browser, go to Docker.com and download the latest Docker Desktop for Windows

Docker Desktop Windows 11 Install 01

  • Click the button on the Homepage to start the download of "Docker Desktop Installer.exe"

Docker Desktop Windows 11 Install 02

Docker Desktop Windows 11 Install 03

  • Open your Downloads folder and double click the executable once finished downloading.

Docker Desktop Windows 11 Install 04

  • Click Yes on the User Account Control window to start the install

Docker Desktop Windows 11 Install 05

  • This installation of Docker Desktop should take about 5 minutes but you may just have time to get a drink.

Docker Desktop Windows 11 Install 06

  • Make sure you have "Use WSL 2 instead of Hyper-V" and "Add shortcut to desktop" ticked in this Configuration window
  • Click Ok to continue.

Docker Desktop Windows 11 Install 07

Docker Desktop Windows 11 Install 08

Docker Desktop Windows 11 Install 09

  • Once the Installation has completed, click the "Close and restart" button to reboot Windows.

Docker Desktop Windows 11 Install 10

  • This Restart will take a lot longer than normal as it will be applying all of the features we enabled earlier.
  • If you didn't get a coffee before I'd definitely suggest getting one now as this will take a while

Docker Desktop Windows 11 Install 11

  • Once you've rebooted and logged back in, you'll see a new shortcut on your Desktop for Docker Desktop.
  • Double click this to open up Docker Desktop for the first time on this machine.

Docker Desktop Windows 11 Install 12

Docker Desktop Windows 11 Install 13

  • Go ahead and click Accept to start up the program after you've read the Docker Subscription Service Agreement.

Docker Desktop Windows 11 Install 14

  • This will open up Docker Desktop for the first time.
  • Untick "Show weekly tips" to stop this window from opening every time you load up the application.

Docker Desktop Windows 11 Install 15

  • You can pick your Role from the dropdown and tick the boxes related to why you are using Docker Desktop. Click Continue once you've made your choice.
  • This is just optional so you can just click Skip

Docker Desktop Windows 11 Install 16

  • This will start up the Docker Engine for the first time.
  • This first time could take up to 10 minutes to load depending on your hardware and any other applications open at the time
  • You are now at in the Containers menu section of Docker Desktop

Docker Desktop Windows 11 Install 17

  • Right now there is nothing here. Click Dismiss in the bottom right to get into the rest of the program
  • This page will normally show any currently running or recently closed Docker Containers

Docker Desktop Windows 11 Install 18

  • Click Images on the left to see where your Docker Images will be downloaded to

Docker Desktop Windows 11 Install 19

  • Click Volumes on the left to see where your created Docker Volumes will be usually found

Docker Desktop Windows 11 Install 20


Testing your Docker Installation - Hello World

We should now have WSL 2, Ubuntu and Docker Desktop installed on Windows.

Let's check it's all working by running our first test Docker container

  • Open up a Windows PowerShell terminal and make sure you Run as Administrator

Docker Desktop Windows 11 Install 21

  • Type the below command wsl and Press Enter to open a WSL shell
wsl
Enter fullscreen mode Exit fullscreen mode

Docker Desktop Windows 11 Install 22

  • This will let you interact with the Ubuntu distro running under WSL

Docker Desktop Windows 11 Install 23

  • Type the below command and Press Enter to check for any running containers
docker ps
Enter fullscreen mode Exit fullscreen mode

Docker Desktop Windows 11 Install 24

Docker Desktop Windows 11 Install 25

  • As you can see there are currently no running containers at the moment
  • To test use the below command to run the Docker Container for Hello-World
docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Docker Desktop Windows 11 Install 26

  • The Docker Image will be downloaded locally, run the container and output a message in the terminal when successful.

Docker Desktop Windows 11 Install 27

Docker Desktop Windows 11 Install 28

  • The Hello-World code has been executed and the Docker Container has been destroyed.
  • If you open up Docker Desktop and now check the Containers section you'll see the container we just ran.
  • It will have a random name which may be different to yours but the Image will be hello-world

Docker Desktop Windows 11 Install 29

  • If you open the Images section you'll see the hello-world image in there now, ready to run without downloading again

Docker Desktop Windows 11 Install 30

  • This container didn't create a Docker Volume so this section is still empty for now

Docker Desktop Windows 11 Install 31

  • Congratulations, you've finally installed Docker on Windows using the WSL 2 backend and even ran a test container.

In our next guide, we’ll set up our first Docker Container on the Raspberry Pi 4 to help block ads and malicious websites on your whole network, Pi-Hole.


Next time on Get Started with Docker - Part 3: Pi-Hole


Don't forget to explore the rest of our website as we build out more content. Stay tuned for more tutorials, tips, and tricks to help you make tech work for you.

If you want to stay up-to-date with regular updates, make sure to subscribe to our free mailing list.


Top comments (0)