As developers, Docker is one of those tools we keep hearing about. I used to think it was a tool for only the DevOps guys but I was wrong. It is a tool for every developer because it solves a very common problem developers face, the classic “it works on my machine” situation where an application runs perfectly on one computer but fails on another because of differences in environments.
Docker fixes this by allowing applications to run inside containers. A container packages the application together with everything it needs to run such as dependencies, runtime, and system libraries. This makes the application behave the same way no matter where it runs. Don’t worry if containers seem unclear now; they’ll become clearer as we progress.
I recently started learning Docker as part of the University of Helsinki Full Stack Open course. As I go through the course, I decided to create a small series where I share what I learn in a simple and practical way.
In this first post, we will focus on setting up Docker on Windows using Docker Desktop and WSL. I will also briefly compare this with installing Docker on Linux and macOS.
Running Docker
Running Docker on Windows is slightly different from running it on Linux. Docker containers rely on features provided by the Linux kernel such as namespaces and control groups. These features make it possible to isolate processes and allocate system resources to containers. Because of this, Docker was originally built to run on Linux systems.
This means that when you run Docker on Windows, there still needs to be a Linux environment somewhere in the background. This is where WSL comes in.
What is WSL?
WSL stands for Windows Subsystem for Linux. It is a feature in Windows that allows you to run a Linux environment directly inside your Windows system.
Instead of running Linux in a traditional virtual machine, WSL provides a lightweight way to use Linux tools and commands alongside your Windows applications.
The latest version, WSL2, includes an actual Linux kernel and offers much better compatibility with Linux applications. This makes it ideal for development workflows that depend on Linux tools, including Docker.
With WSL installed, you can open a Linux terminal like bash and run commands just like you would on a normal Linux machine and do things like installing Linux apps or hacking NASA.
Docker Desktop
Even though WSL provides a Linux environment, Docker still needs a component called the Docker Engine to manage containers. On a native Linux machine, you can install and run the Docker Engine directly on the operating system. Windows works differently, you’ll need Docker Desktop.
Docker Desktop acts as the bridge that connects Docker with WSL. It installs and manages the Docker Engine inside a Linux environment and integrates it with your Windows system.
Docker Desktop also provides a number of helpful features such as:
- automatic management of the Docker engine
- integration with WSL distributions like Ubuntu
- a graphical interface for managing containers
- networking and port forwarding between Windows and containers
Because of these features, Docker Desktop is usually the easiest and most reliable way to run Docker on Windows.
The diagram below illustrates the relationship between your Windows System, Docker Desktop and WSL
Press enter or click to view image in full size
Relationship between Windows System, Docker Desktop and WSL
Installing and Configuring the Components
Enough explanations, its time for installation and configuration of the different components I mentioned above. Since docker needs a Linux environment to run, we’ll begin with the installation of WSL then Docker Desktop and finally configure WSL integration with Docker Desktop.
Installing WSL
To enable WSL, open PowerShell as administrator and run:
wsl --install
This command installs WSL and downloads a default Linux distribution, usually Ubuntu.
After installation, restart your computer and verify that WSL is installed with:
wsl -l -v
You should see something like this:
Press enter or click to view image in full size
Installed WSL Distros
Make sure the version shown is 2, since Docker requires WSL2 for proper functionality.
If you already have WSL enabled for your PC — awesome, otherwise I hope this short guide helped.
After enabling WSL, you can access the Linux environment by opening PowerShell and running command: wsl
Press enter or click to view image in full size
The mounted path mirrors your previous Windows path where you ran the wsl command. The prefix mnt/c/Users/… typically signifies that you are accessing your Windows drive. You can switch to the root of the Linux drive with the command cd ~
Alternative, you can just open PowerShell, click on the (**v**) icon next to the open a new tab icon (**+**) and choose Ubuntu to get to the root of the Linux drive immediately.
Press enter or click to view image in full size
Opening Ubuntu
Installing Docker Desktop
This is pretty straight forward, download Docker Desktop from https://www.docker.com/products/docker-desktop/
Run the installer and follow the setup instructions. During installation, Docker Desktop will detect WSL and you simply tick the WSL 2 option to use it. Once the installation is complete, restart your PC and start Docker Desktop and sign in preferably with your GitHub account.
Press enter or click to view image in full size
Installing Docker
Press enter or click to view image in full size
Docker Desktop Interface
This installs the Docker CLI on the Windows side and runs the Docker Engine inside a special WSL distribution that Docker Desktop creates. This means you can run Docker commands from PowerShell, Command Prompt, Windows Terminal, or your WSL Linux terminal. All of these interfaces communicate with the same Docker Engine running inside WSL.
For optimal speed and performance, it's generally preferable to run Docker commands within the WSL environment rather than directly in Windows.
More About Docker Desktop
Another interesting thing that Docker Desktop does is that it creates two internal WSL distributions distros:
-
docker-desktop: runs the Docker Engine (
dockerd) and other Docker services. - docker-desktop-data: stores Docker data such as images, volumes, containers etc. (This is hidden in recent Docker Desktop versions to prevent access/modification of Docker data)
You can actually see the docker-desktop distro in addition to the default Ubuntu distro that was previously installed if you run:
wsl -l -v
Press enter or click to view image in full size
Installed WSL Distros
A more accurate illustration of the relationship between your Windows System, Docker Desktop and WSL would be:
Press enter or click to view image in full size
Updated relationship between Windows System, Docker Desktop and WSL
The Docker Desktop application automatically manages both docker-desktop and docker-desktop-data for you. It is recommended not to manually access or interact with these distributions from WSL, even though it is technically possible.
I maybe digressing to some of the inner workings of Docker Desktop and honestly at this point some of the terms mentioned here may be strange but hang on a bit, we’ll be getting to those soon.
It took me a while to understand these relationships, you may need to revisit this article again to gain a clearer understanding of some of the mentioned terms and concepts
Connecting Docker Desktop to WSL Ubuntu
To connect Docker Desktop to your WSL Ubuntu distribution, open the Docker Desktop application and go to:
Settings → Resources → WSL Integration
Press enter or click to view image in full size
Connecting Docker Desktop to WSL Ubuntu
Enable integration for your Linux distribution (Ubuntu) and apply the changes. This allows Docker commands like docker container ls run inside your WSL terminal to communicate with the Docker Engine managed by Docker Desktop.
To verify the installation was successful, and check that docker is installed. Open your WSL terminal and run docker -v
Press enter or click to view image in full size
Verification of docker installation
Installing Docker on Linux
Installing Docker on Linux is usually simpler because the operating system already includes the kernel features Docker requires.
For example, on Ubuntu you can install Docker with:
sudo apt update
sudo apt install docker.io
Once installed, Docker runs directly on the system without needing Docker Desktop or any additional tools.
Installing Docker on macOS
macOS is similar to Windows in the sense that it does not use the Linux kernel.
Because of this, Docker typically runs inside a lightweight virtual machine on macOS. Docker Desktop is commonly used to manage this setup and provide a seamless experience for developers.
Conclusion
Docker has become an essential tool in modern development because it allows applications to run in consistent environments across different machines.
Installing Docker on Windows involves a few extra steps because Docker depends on Linux features. WSL provides the Linux environment, while Docker Desktop manages the Docker engine and integrates it with your system.
Linux users usually have a simpler installation process because Docker can run directly on the operating system. macOS, like Windows, typically relies on Docker Desktop to provide the required environment.
This post is the first in my Docker series where I share what I learn about Docker while taking the Full Stack Open course on containers. In the next post, we will take a closer look at Docker images and containers and how they form the foundation of Docker workflows.
Thank you for reading, I hope to see you again in the next part of this Docker for beginners series.










Top comments (0)