Docker 101: Installation Guide

PART II

Docker 101: Installation Guide

Running Windows and Linux Containers on Windows:

  • To run a Windows container on a Windows host, you don't need a virtual machine.

  • Containers are isolated environments where applications run, interacting with the host OS and kernel.

  • Windows-based containers won't run on Linux-based Docker containers; they require a Windows system to operate.

  • Running Linux containers on a Windows host, a virtual machine is often used to create an isolated environment where these containers can operate. Two common ways to set up this virtual machine are through:

    1. Docker Desktop: Docker Desktop is a tool for Windows that simplifies the process of running Docker containers, including Linux containers. It manages a virtual machine in the background that handles the Linux-based containers, allowing them to run alongside Windows containers on a Windows host.

    2. PREFERRED Windows Subsystem for Linux (WSL): WSL is a compatibility layer for running Linux binary executables natively on Windows. You can install a Linux distribution on WSL (e.g., Ubuntu), and this Linux environment can be used to run Linux containers, making it possible to work with both Windows and Linux containers on the same Windows machine.

In both cases, a virtual machine is involved in running Linux containers on a Windows host to provide the necessary compatibility and isolation.

INSTALLING DOCKER ON WINDOWS

Requirements:

  • A 64-bit version of Windows 10 or Windows Server 2016 (or later) is required.

  • You must have hardware virtualization enabled in your BIOS.

Installation Steps:

  1. Install Windows Subsystem for Linux (WSL):

    • Open PowerShell as an administrator.

    • Check if WSL is already installed:

        wsl --status
      
    • View available Linux distributions that can be downloaded:

        wsl --list --online
      
  2. Install a Linux Distribution:

    • You need to install a Linux distribution to run Docker.
    wsl --install -d Debian
  • Run the following command to enable the WSL feature:
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  • Restart your computer.
  1. Upgrade WSL 2:

    • Open PowerShell as an administrator.

    • Check the WSL version:

        wsl --status
      
    • If already have version 2 then skip next sub-steps

    • Run the following command to set WSL from version 1 to 2 as the default version:

        wsl --set-default-version 2
      
    • Reinstall your chosen Linux distribution for version 2:

        wsl --set-version Debian 2
        wsl --update
      
  2. Install Docker Desktop:

  3. Enable WSL Integration in Docker Desktop:

    • After installing Docker Desktop, open it.

    • In the Docker Desktop settings, go to "Resources" and then "WSL Integration."

    • Enable WSL integration for the Linux distribution you installed (e.g., Ubuntu).

  4. Docker Engine Configuration:

    • Set buildkit to false in Docker Engine configuration.

        {
          "builder": {
            "gc": {
              "defaultKeepStorage": "20GB",
              "enabled": true
            }
          },
          "experimental": false,
          "feature": {
            "buildkit": false
          }
        }
      
    • In your Docker Desktop extension settings, check the box for "Allow only extensions distributed through the Docker Marketplace."

  5. Resource Allocation (Optional):

    • In Docker Desktop's "Resources" > "Advanced," you can configure limits on memory, CPU, and swap size allocated to WSL 2 by setting up a .wslconfig file⁠.
  6. Apply and Restart:

    • Click "Apply" in Docker Desktop settings and restart the application.
  7. Test Docker:

    • In your Linux distribution terminal (e.g., Ubuntu), run Docker commands to create and manage containers.

With these steps completed, you should have Docker successfully installed and integrated with Windows through WSL. You can now create and manage containers on your Windows machine.

Docker desktop includes:

REFERENCE