avatarCumhur Akkaya

Summary

The provided content outlines a comprehensive guide to installing and running Ubuntu with WSL (Windows Subsystem for Linux) and Docker Desktop on Windows 10/11, detailing the necessary steps and configurations to leverage Docker containers within a Linux environment on a Windows machine.

Abstract

The web content serves as a detailed tutorial for setting up a Linux development environment on a Windows system using WSL 2 and Docker Desktop. It begins by explaining the concepts of Docker, Docker Desktop, and WSL, including the differences between virtual machines and Docker containers. The guide then proceeds to list the system requirements for installing Docker Desktop with WSL 2 backend, followed by a step-by-step installation process for Ubuntu 20.04 (WSL), WSL version 1.1.3.0 or later, and Docker Desktop. It includes instructions for setting up Windows features, downloading the Linux kernel update package, and configuring WSL 2 as the default version. The article also covers the installation of Ubuntu via the Microsoft Store, setting up a Linux username and password, and updating and upgrading packages. Once Ubuntu and WSL 2 are set up, the guide explains how to install Docker Desktop, configure its settings, and verify the installation by running a Docker container. Additionally, it provides insights into resource configuration for Docker Desktop and how to configure the Docker daemon. The article concludes by encouraging readers to follow the author on Medium and LinkedIn for future content on Cloud and DevOps topics.

Opinions

  • The author emphasizes the ease and speed of installing a complete Ubuntu terminal environment using WSL on Windows.
  • The use of Docker Desktop is presented as a user-friendly application that simplifies the management of containerized applications, with both GUI and CLI options available.
  • The integration of Docker with WSL 2 is highlighted as beneficial for improved performance and compatibility, allowing developers to work within a Linux environment without leaving Windows.
  • The article suggests that following the provided instructions will enhance cross-platform application development, data science workflows, and web development processes.
  • The author expresses a belief in the importance of community engagement by asking readers to follow, clap, or subscribe, which helps their articles reach a broader audience.
  • The guide is written with the intention of empowering developers to quickly adapt to Docker and WSL technologies, thereby accelerating their software delivery cycles.

Docker Desktop-1: Installing and Running Ubuntu with WSL (Windows Subsystem for Linux) and Docker Desktop on Windows 10/11

We will install a complete Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL) on Windows 10/11. So you can develop cross-platform applications, improve your data science or web development workflows, and manage IT infrastructure without leaving Windows. Then, We will install Docker Desktop on Windows. After making the necessary settings in the Docker Desktop, we will run Docker commands in the Windows terminal, and run a container. We will observe and examine the running of the container in the browser and Docker Desktop.

Topics we will cover:

1. What are the Docker, Docker Desktop, and WSL? 2. System requirements (WSL 2 backend) to Install Docker Desktop 3. Installing Ubuntu 20.04 (WSL) and WSL version 1.1.3.0 or later 3. a. Setting Up “Windows Feature” 3. b. Download and Install the Linux kernel update package(wsl_update_x64.msi) 3. c. Setting WSL 2 as your default version 3. d. Installing Ubuntu 20.04 (WSL) on Windows by using the WSL install command 3. e. Installing by using the Microsoft Store 3. f. Setting your Linux username and password 3. g. Updating and Upgrading packages for the default Ubuntu distribution using apt 4. Installing Docker Desktop on Windows 5. Starting and Setting Docker Desktop on Windows 6. Checking Docker Desktop’s running 7. Configuring Resources 8. Configuring Desktop’s Docker Daemon in the Docker Engine

9. As a result 10. Next post 11. References

If you like the article, I will be happy if you click on the Medium Following button to encourage me to write more, and not miss future articles.

Your clap, follow, or subscribe, they help my articles to reach the broader audience. Thank you in advance for them.

1. What is the Docker, Docker Desktop and Docker in WSL2?

Figure 1 - Difference between Virtual Machines and Docker Containers (Source: Docker)

Docker is an open-source container technology that allows us to build independent and isolated containers on the same operating system and test our application, as shown in Figure 1. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production. (1)

Figure 2 - Docker Desktop architecture (Source: freecodecamp)

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. It provides a straightforward GUI (Graphical User Interface) that lets you manage your containers, applications, and images directly from your machine, as shown in Figure 2. Docker Desktop can be used either on its own or as a complementary tool to the CLI. Docker Desktop reduces the time spent on complex setups so you can focus on writing code. (2)

Figure 3 - WSL1 and WSL2

What is WSL? WSL allows you to install and run Linux distributions on Windows. This can be a bit confusing since Linux, like Windows, is an operating system (operating system)… so you’re basically running two operating systems integrated with each other. (3)

Figure 4- Using Docker in WSL 2 (Source: https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2)

Using Docker in WSL 2: This new Docker architecture works a lot like Visual Studio Code’s WSL remote development support in that the Docker CLI running on the host machine executes commands within the Docker Integration Package, which runs on the remote WSL VM. DockerD runs directly within WSL so there’s no need for the Hyper-V VM and all Linux containers run within the Linux userspace on Windows for improved performance and compatibility, as shown in Figure 4.

2. System requirements (WSL 2 backend) to Install Docker Desktop

I. WSL version 1.1.3.0 or later. We will do this step by step in the next item 3. II. Turn on the WSL 2 feature on Windows. For detailed instructions, refer to the Microsoft documentation. We will do this step by step in the next item 3. III. Windows 10 64-bit: Home or Pro 21H2 (build 19044) or higher, or Enterprise or Education 21H2 (build 19044) or higher.

Open About settings to check the version of Windows you are currently running and, if necessary, update to a new version. For this, press the Windows Key + X to open the power user menu and click on system. You should be able to see your system type under device specifications.

VI. Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher. V. The following Hardware Prerequisites are required to successfully run WSL 2 on Windows 10 or Windows 11:

Figure 5

3. Installing Ubuntu 20.04 (WSL) and WSL version 1.1.3.0 or later.

I installed Ubuntu 20.04 (WSL) on my own system from Microsoft Store, as shown in Figure 6.

Figure 6

If you want to install Ubuntu 20.04 (WSL) too, follow the steps below:

3. a. Setting Up “Windows Feature”

Go to the Start menu > Settings app > Apps & features > Programs and Features > Apps. Here, click on “Turn Windows features on or off”.

Before installing Ubuntu 20.04 (WSL), make sure that the three boxes marked below are selected in Windows. Check the Windows Subsystem for Linux, Hyper-V, Virtual Machine Platform checkboxes as marked, as shown in Figure 7.

Then, click on the “Ok” button, and click on the “Restart now” button. These will become active after restarting your computer.

Figure 7

3. b. Download and Install the Linux kernel update package (wsl_update_x64.msi)

Download the Linux kernel update package (the WSL 2 feature) on Windows. For this, you should download the file named WSL2 Linux kernel update package for x64 machines, to download, click on this address. When the download is finished, double-click on the “wsl_update_x64.msi” file to start the installation, and install it on your device, as shown in Figure 14.

Figure 14

Note: Check this link for Troubleshooting Windows Subsystem for Linux

3. c. Setting WSL 2 as your default version

Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:

wsl --set-default-version 2

# Check to output:
wsl.exe -l -v

3. d. Installing Ubuntu 20.04 (WSL) on Windows by using the WSL install command

Figure 8
  • Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting “Run as administrator”. (4)
  • Enter your command:wsl --install, as shown in Figure 8.
  • To start using WSL, you need to restart your machine after this installation.

Note: Check this link for basic WSL commands.

  • The command wsl --install installs the Ubuntu distribution of Linux by default. You can choose a different Linux distribution from the list available in the Microsoft Store. You can also install additional Linux distributions after installing the default Ubuntu. To choose an alternative to the default Ubuntu distribution or to install additional distributions from the repository, use the command:wsl --install --distribution <Distribution Name>, as shown in Figure 9. (5)https://learn.microsoft.com/en-us/windows/wsl/install#change-the-default-linux-distribution-installed

Note: To see which distributions are currently available through the repository, enter the command: wsl --list --online

Figure 9

3. e. Installing by using the Microsoft Store

  • Start the Microsoft Store application, as shown in Figure 10.
Figure 10

Select the version of Ubuntu (WSL) you want to install, as shown in Figure 11.

It installs a complete Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL). Develop cross-platform applications, improve your data science or web development workflows and manage IT infrastructure without leaving Windows.

Figure 11

Click the Install(yükle) button, as shown in Figure 12. When the installation is finished, start Ubuntu (WSL) by clicking the “Ubuntu 20.04.6 LTS” icon in the Start menu.

Figure 12

Ubuntu (WSL) will start automatically after the installation is finished.

3. f. Setting your Linux username and password

After starting Ubuntu, you have to create a user account on Ubuntu now. (5)(after it’s installed you can find it in the Windows search menu).

  • Type in the username and press, as shown in Figure 9.
  • Then, type in a new password for the username you picked and press.
  • Then, retype the password and press. A new user for Ubuntu should be created.
  • Finally, you can run any Ubuntu Linux command here. I ran the lsb_release -a command and as you can see in the screenshot below, I am running Ubuntu 20.04.6 LTS on Windows 10 through WSL, as shown in Figure 13.
Figure 13

3. g. Updating and Upgrading packages for the default Ubuntu distribution using apt

  1. Open Ubuntu (after it’s installed you can find it in the Windows search menu).
  2. Enter your command:sudo apt update && upgrade
  3. Updating and upgrading packages requires elevated “sudo” (superuser do) permissions, so you must also enter the password you created for the Linux distribution. (6)

4. Installing Docker Desktop on Windows

Firstly, download and install the latest version of Docker Desktop for Windows click the link. (7)

Double-click on the downloaded “Docker Desktop Installer.exe” file to start the installation. Installation starts, as shown in Figure 15.

Figure 15

When prompted, ensure the “Use WSL 2 instead of Hyper-V”(required) and “Add shortcut to desktop”(optional) options on the Configuration page are selected, as shown in Figure 16. And then click on the “Ok” button.

Figure 16

Installation continues, as shown in Figure 17.

Figure 17

When the installation is successful, select Close to complete the installation process, as shown in Figure 18.

Figure 18

Note: If you get the error indicated in the screenshot (as shown in Figure 19), you need to install the Linux kernel for Windows. We can download it from the specified link and complete the installation, as described in item 2. g.

Figure 19

5. Starting and Setting Docker Desktop on Windows

Docker Desktop does not start automatically after installation. To start Docker Desktop:

  1. Search for Docker, and select Docker Desktop in the search results, as shown in Figure 20, OR Double-click on the “Docker Desktop” icon on your desktop, and then accept to Service Agreement, as shown in Figure 21.
Figure 20
Figure 21

Choose the ones that suit you in “What’s your role?” and “What will you use Docker for?”, as shown in Figure 22.

Figure 22

Click on the “gear” button, as shown in Figure 23.

Figure 23

Go to the “Resource > WSL integration” tab and check, whether the box of “Enable integration with my default WSL distro” is ticked, as shown in Figure 24.

Figure 24

Go to the General tab and make sure that the “Use the WSL 2 Based Engine” field is checked, as shown in Figure 25.

Figure 25

Our Docker installation is complete. Now you can run your codes from the CMD screen, as shown in Figure 26.

Figure 26

6. Checking Docker Desktop’s Running

Then start a container to verify your setup is working, following the command in Windows PowerShell, as shown in Figure 27.

docker run -d -p 80:80 docker/getting-started
Figure 27

We checked that our container was created in Docker Desktop, as shown in Figure 28.

Figure 28

In the “Containers” tab, Your new container should appear in the Docker Desktop UI. Clicking the ellipsis icon to the right of the table displays a list of actions you can perform within Docker Desktop, such as opening a terminal within the container or visiting published ports in your browser. We selected “Open in the browser”, as shown in Figure 29.

Figure 29

The page of the image in the container is opened in our browser, as shown in Figure 30.

Figure 30

The “Images” tab on the left side of the screen provides a table of all container images available on your server. Controls are available to delete, push and pull images between different registries, as shown in Figure 31.

Figure 31

7. Configuring Resources

The “Resources > Advanced” tab on the left side of the screen allows you to configure CPU, memory, disk, proxies, network, and other resources. We can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file, as shown in Figure 32. (8)

The “Resources > Proxies” tab allows you to configure HTTP/HTTPS proxies.

The “Resources > Network” tab, Docker Desktop uses a private IPv4 network for internal services such as a DNS server and an HTTP proxy. In case Docker Desktop’s choice of subnet clashes with IPs in your environment, you can specify a custom subnet using the Network setting.

Figure 32

8. Configuring Desktop’s Docker Daemon in the Docker Engine

The Docker Engine tab allows you to configure the Docker daemon used to run containers with the Docker Desktop. You can customize the Docker daemon configuration used by Desktop by clicking the settings gear icon in the title bar and going to the Docker Engine tab on the left of the screen, as shown in Figure 33. (8)

Figure 33

For example: To allow Docker Registry insecure connections on Windows, enter the Docker Client program and go to the Docker Engine tab from the Settings page and add the following parameter to the end of the configuration. Replace and save the IP address and port of the device you installed Docker Registry with, and restart the Docker service, as shown in Figure 34.

"insecure-registries" : ["IPADDRESS:PORT"]
Figure 34

9. As a result

We successfully installed a complete Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL) on Windows. Then, We installed Docker Desktop on Windows. After making the necessary settings in the Docker Desktop, we run Docker commands in the Windows terminal.

If you liked the article, I would be happy if you click on the Medium Following button to encourage me to write and not miss future articles.

Your clap, follow, or subscribe, they help my articles to reach the broader audience. Thank you in advance for them.

For more info and questions, please contact me on Linkedin or Medium.

10. Next post

In the next post, Docker Desktop-2: Deploying an application by using Kubernetes Yaml File to Docker Desktop Kubernetes Cluster integrated with VS Code”.

We will enable Kubernetes on Docker Desktop. Docker Desktop has integrated Kubernetes support but it is not enabled by default. And then we will deploy an application by using Kubernetes Yaml File to the Docker Desktop Kubernetes Cluster. We will observe and examine the running of our application in the browser and Docker Desktop.

I hope you enjoyed reading this article. You can share this article with friends in your network and help them to upskill.

I frequently share articles about Cloud and DevOps tools and resources, if you follow me on my Medium or LinkedIn account you don’t miss future articles. I wish you growing success in the DevOps and the Cloud way.

Happy Clouding…

11. References

(1) https://docs.docker.com/get-started/overview/

(2) https://docs.docker.com/desktop/?_gl=1*28tvt8*_ga*MTcyNTM2NTk0NS4xNjkzMTQ5Mzcw*_ga_XJWPQMJYHQ*MTY5MzY1ODQ0OS4xOC4xLjE2OTM2NTg3ODQuNTYuMC4w

(3) https://learn.microsoft.com/tr-tr/training/modules/wsl-introduction/what-is-wsl

(4) https://learn.microsoft.com/tr-tr/training/modules/wsl-introduction/install-and-setup

(5) https://learn.microsoft.com/tr-tr/training/modules/wsl-introduction/install-and-setup

(6) https://learn.microsoft.com/tr-tr/training/modules/wsl-introduction/install-and-setup

(7) https://docs.docker.com/desktop/wsl/#download

(8) https://docs.docker.com/desktop/settings/windows/

Docker Desktop
Ubuntu Windows Installer
Wsl 2
Microsoft Store
Wsl Update
Recommended from ReadMedium