Cloud Native 9 min read

Quickly Set Up Docker on Windows with WSL2, Ubuntu, and Portainer

This step‑by‑step tutorial shows how to install Windows 10, enable WSL2, set up an Ubuntu subsystem, install Docker and Portainer, and configure a convenient development environment on Windows within half an hour.

macrozheng
macrozheng
macrozheng
Quickly Set Up Docker on Windows with WSL2, Ubuntu, and Portainer

The author’s MacBook required repair, so they switched to Windows and needed a smooth Docker setup; this guide walks through installing Docker on Windows using WSL2, Ubuntu, and Portainer.

1. Install WSL2

1.1 Install Windows Terminal

Download

Windows Terminal

from the Microsoft Store; it provides a macOS‑like experience similar to iTerm.

1.2 Enable WSL2

Open the Control Panel, select "Turn Windows features on or off", and check "Windows Subsystem for Linux".

Upgrade to the latest Windows 10 version, then run the following PowerShell command to set WSL2 as the default:

<code>wsl --set-default-version 2</code>

2. Install Ubuntu Subsystem

Install the Ubuntu LTS version from the Microsoft Store; after installation, select it from the dropdown arrow in Windows Terminal.

Once inside Ubuntu, replace the default apt sources with faster mirrors:

<code>deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</code>

Install

oh‑my‑zsh

for an improved shell:

<code>sudo apt install zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"</code>

3. Install Docker

Download Docker Desktop for Windows from the official site and follow the default installation steps.

<code>https://www.docker.com/products/docker-desktop</code>

After launching Docker, open Settings and replace the default registry with a reachable mirror, for example:

<code>["https://registry.docker-cn.com",
 "https://dockerhub.azk8s.cn",
 "https://reg-mirror.qiniu.com",
 "http://hub-mirror.c.163.com",
 "https://docker.mirrors.ustc.edu.cn"]</code>

Apply the changes and restart Docker.

4. Install Portainer

Portainer provides a web UI for managing Docker containers. In the Ubuntu WSL2 terminal, run:

<code>docker volume create portainer_data
docker run -d -p 9000:9000 -p 8000:8000 --name portainer \
  --restart always -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data portainer/portainer</code>

Access

http://localhost:9000

in a browser to complete the setup.

With Docker and Portainer ready, you can quickly launch services such as MySQL via containers, use the built‑in web terminal, and avoid time‑consuming native installations.

End

The Docker development environment is now fully set up; command‑line users can operate Docker directly through WSL2, while newcomers can rely on Portainer’s UI for easier management.

DockerContainerizationwindowsUbuntuWSL2Portainer
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.