Goal:

  • preparation of a basic set of tools for working with containers for the Windows system based on WSL2 and Docker Desktop.
  • use this procedure only if you have a current Windows 10 or newer operating system.

You need:

  • Windows 10, version 2004 or higher. The build number must be 19041+. If your version of Windows does not fit, Windows Update or this guide can help. You can find out the exact version with the winver command.
  • At least 4GB RAM and 64bit system
  • Enabled support virtualization in BIOS.

The result will look something like this:

+ ----------------+                      +---------------+
| Ubuntu on WSL2  |                      | Docker Engine |
| Docker CLI      |  <--connection---->  | and WSL2      |
+ ----------------+  via virtual network +---------------+
         ^                                     ^
         |                                     |
  Windows Terminal                       Docker Desktop

Procedure:

  1. Install WSL2 and Ubuntu Linux. After this tutorial, you should have installed:

    • WSL2, Windows Subsystem for Linux 2 - a virtual machine for installing Linux using Hyper-V.
    • Ubuntu 20.04 - complete Ubuntu environment.
  2. Install Windows Terminal - a convenient command line to connect to Ubuntu virtual machine or other.

  3. Try if WSL2 works.

    • Start Windows Terminal using the Start menu.
    • Tap the arrow and select "Ubuntu 20.04". The Ubuntu command line will start.
    • Find out the IP address of the Ubuntu machine: ip address.
    • Antivirus software sometimes makes the network within WSL2 unavailable.
  4. Then install Docker Desktop. You will get:

    • Docker Engine: a virtual machine that takes care of running containers. The virtual machine uses WSL2 and Hyper-V subsystems.
    • Docker CLI: utility for communication with Docker Engine.
    • Kubernetes: an orchestrator for building more complex container deployments.
  5. Try if Docker works.

    • The "Docker Desktop" icon and the message "Docker is running" should appear in the lower right corner of the computer.
  6. Connect the inline Docker client and Docker Engine.

    • Run Ubuntu 20.04 using Windows Terminal
    • Install the necessary packages:
       sudo apt-get update
       sudo apt-get upgrade
       sudo apt-get install docker.io vim
    • Create a link:
      • Tap on the "Docker Desktop" icon.
      • Select the "Settings" icon.
      • Find the menu Resources/WSL Integration.
      • Enable "Enable integration with additional distros".
    • Check if it works.

Finally, in the Ubuntu command line, type docker version.

Something like this will be written:

Client:
  Version: 19.03.8
  API version: 1.40
  Go version: go1.13.8
  Git commit: afacb8b7f0
  Built: Fri Dec 18 12:15:19 2020
  OS/Arch: linux/amd64
  Experimental: true

Server: Docker Engine - Community
  Engine:
   Version: 20.10.2
   API version: 1.41 (minimum version 1.12)
   Go version: go1.13.15
   Git commit: 8891c58
   Built: Mon Dec 28 16:15:28 2020
   OS/Arch: linux/amd64
   Experimental: false
  contained:
   Version: 1.4.3
   GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
  run:
   Version: 1.0.0-rc92
   GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
  docker-init:
   Version: 0.19.0
   GitCommit: de40ad0

In case an error message is displayed, it is necessary to "restore" the integration of Docker and WSL.

Open Docker Desktop and tap on the "Settings" icon. In the menu, find the "Resources" and "Integration" sections. Make sure all the sections are checked, similar to the picture.

WSL

Next Post

Week 1: Installing Docker Desktop