Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 10 / Get Started with Docker on Windows (WSL2) without Docker Desktop

September 4, 2024

Get Started with Docker on Windows (WSL2) without Docker Desktop

There are two ways to install the Docker containerization platform on Windows 10 and 11. It can be installed as a Docker Desktop for Windows app (uses the built-in Hyper-V + Windows Containers features), or as a full Docker Engine installed in a Linux distro running in the Windows Subsystem for Linux (WSL2). This guide will walk you through the installation and basic configuration of Docker Engine in a WSL environment without using Docker Desktop.

Advantages of using Docker Engine in WSL:

  • Pro or Enterprise edition of Windows 10/11 is required for Docker Desktop. The Docker Engine in WSL can even run on Windows Home editions
  • Docker Desktop for Windows requires additional RAM and disk space to run Hyper-V virtual machines and additional Windows containers
  • Docker Desktop is free for small businesses (up to 250 employees), personal, and non-commercial projects. In other cases, you will need to purchase a paid subscription.

Suppose you already have a WSL2 (Windows Subsystem for Linux) environment installed on your Windows computer with one of the available Linux images (Ubuntu:22.04 in this example). List available WSL distributions:

wsl --list

To set the default WSL image, run the command:

wsl --setdefault Ubuntu-24.04

wsl list disributions

Make sure you are using WSL2:

wsl --version

wsl - check versio

If not, run:

wsl --set-default-version 2

Connect to your Linux image in the WSL environment:

wsl.exe

Update packages in your Linux distro (Ubuntu in this case):

$ sudo apt-get update && sudo apt-get upgrade -y

Then install the Docker Engine on Linux using the official script:
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

Ignore the warning about installing Docker in a WSL environment.

WSL: install docker engine get-docker.sh

Add your user to the docker group. This allows you to run the Docker commands without having to elevate privileges with sudo or entering a password.

$ sudo usermod -aG docker $USER

Verify that Docker Engine and Compose have been successfully installed:

$ docker --version
$ docker compose version

Check Docker Engine version on Windows WSL

Now configure the Docker daemon to start automatically in WSL. WSL currently fully supports systemd (the init system and service manager used by many popular Linux distros). Check that it is enabled in your WSL Linux image:

$ cat /etc/wsl.conf

[boot]
systemd=true

enable systemd in WSL

Then check that systemd is used as the Linux init system:

$ stat /sbin/init

In this case, systemd is used for init (because the /sbin/init is a symbolic link to /lib/systemd/systemd).

check if systemd is enabled

Run the Docker Engine service and enable autostart:

$ sudo systemctl enable --now docker.service
$ systemctl status docker.service

systemctl enable docker.service in WSL

If for some reason systemd is not used, you can add it to the WSL startup:

$ nano /etc/wsl.conf

[boot]
command = "/usr/sbin/service docker start"

The following host computer resources are available to WSL2 by default:

  • 50% of RAM
  • 25% of swap file
  • 100% of the CPU resources

If you want to restrict the use of host resources by the WSL2 subsystem, create a text file %UserProfile%\.wslconfig in the current user’s profile. This file can be used to set global restrictions for all WSL distros. For example, add the following:

[wsl2]
memory=8GB
processors=4
swap=2GB

Restart the WSL image from the Windows command prompt:

wsl --shutdown

Run a test Docker container in WSL:

$ docker run hello-world

Docker Engine will download and run the hello-world demo container from the Docker Hub.

To get the best performance from WSL2, store all your Docker container files inside WSL, rather than in directories that are redirected from the Windows host (such as /mnt/c).

Modern Linux versions (Ubuntu 22.04, Debian 10+) use nftables instead of iptables to manage the built-in firewall. Linux kernel 5.8 or later required for native nftables support in WSL. To make the network work properly with old kernels, enable compatibility with iptables:

$ sudo update-alternatives --config iptables

WSL: switch to iptables (update-alternatives)
Press 1 to select iptables-legacy mode.

You can now run Docker commands in WSL from the Windows command prompt.

Before any Docker command, you must specify wsl. For example, list available Docker images:

wsl docker images
Windows - list available Docker images in WSL
Now you can develop and run Docker containers on your Windows machine.

2 comments
9
Facebook Twitter Google + Pinterest
LinuxWindows 10Windows 11
previous post
Adding Multiple Alternate DNS Names for a Windows Computer
next post
How to Cast/Mirror Android Screen to Windows PC

Related Reading

Create a Custom Windows Image with Pre-installed Apps

February 28, 2024

Upgrading to Windows 11 on Unsupported Hardware

March 6, 2024

Configuring RemoteApps Hosted on Windows 10/11 (without Windows...

January 25, 2025

Installing Language Pack in Windows 10/11 with PowerShell

September 20, 2023

How to Assign (Passthrough) a Physical GPU to...

June 11, 2024

Fix: Your IT Administrator Has Limited Access to...

March 22, 2024

How to Create UEFI Bootable USB Drive to...

March 13, 2024

Enable Hyper-V on Windows 10/11 Pro and Home...

August 12, 2024

2 comments

Jason September 16, 2024 - 8:50 pm

This was very helpful, thank you for providing it!

Reply
Gin February 14, 2025 - 9:42 am

Thank you, this was very straightforward and worked without issue. Although this method was buried in the official docs, this was easier to understand.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Failed to Open the Group Policy Object on a Computer

    June 2, 2025
  • Remote Desktop Printing with RD Easy Print Redirection

    June 2, 2025
  • Disable the Lock Screen Widgets in Windows 11

    May 26, 2025
  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fixing ‘The Network Path Was Not Found’ 0x80070035 Error Code on Windows
  • Recovering Files from BitLocker Encrypted Drive
  • Install Any OS from ISO Image over Network with iVentoy
  • Monitoring Domain Name Expiration Date with Zabbix
  • Turn Linux Computer into Wi-Fi Access Point (Hotspot)
  • Printing from Linux to a Windows Shared Printer
  • Adding Trusted Root Certificates on Linux
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top