AutoNetOps

Cover Image for Setup Docker on Windows with WSL

Setup Docker on Windows with WSL

3 min read

Docker will be very useful for our future network automation tests and labs, so we will have a quick walk-through on how I set up my environment.

Prerequisites

WSL

  • Windows 10 version 2004 and higher or Windows 11

Docker

  • 64-bit processor

  • 4GB RAM

  • Hardware Virtualization enabled


Explaining the Options

To run Docker we can follow two lines

  • Install a Linux distro and within it, install and run Docker

  • Install WSL2 on Windows

I will proceed by installing a Linux distro for our code development area while running Docker on Windows. From the Linux environment, we will still be able to use Docker commands and also check Docker Desktop when needed. I believe this is more beginner-friendly, so this is the choice adopted.


How to install Linux on Windows with WSL

WSL supports running multiple Linux distributions, and there are several ways to run them once installed.

How we will do
We will use Ubuntu and connect it to our Visual Studio editor. Check out more options here.

You can install everything you need to run WSL with a single command. Open PowerShell or Prompt in administrator mode. Enter the wsl --install -d <Distribution Name> command, then restart your machine.

By default, if -d is not specified, the installed Linux distribution will be Ubuntu.

See a list of available Linux distributions available for download: wsl --list --online.


WSL Version

New Linux installations, installed using the wsl --install command, will be set to WSL 2 by default

To double-check whether your Linux distribution is set to WSL 1 or WSL 2, use the command: wsl -l -v.

Upgrade/Downgrade
The wsl --set-version command can be used to downgrade from WSL 2 to WSL 1 or to update previously installed Linux distributions from WSL 1 to WSL 2.

💡
Once you have installed WSL, you will need to create a user account and password for your newly installed Linux distribution. Make sure not to forget it.

VisualStudio w/ WSL

On VisualStudio Code, add the extension for WSL.

On the bottom left, there is a button to manage your VS connections:

Then choose your distro to connect:

After that, you'll be ready to start using your Linux terminal:

Reference

Up to this point, the tutorial summarizes the options Microsoft provides for setting up your environment. Please refer to their official documentation if needed.

Install Docker Desktop

Docker Desktop is a one-click-install application for your Mac, Linux, or Windows environment that lets you build, share, and run containerized applications and microservices.

Check out the official site to install the latest version. It is quite simple. Download the installer and run it.

When you launch it, you will see this:

That is it for today. We have the foundation to start building our networking labs.

Thank you for your time!