DEV Community

Cover image for How Docker works on windows
koya
koya

Posted on

How Docker works on windows

Hello, I'm Koya. Software engineer in Japan.

This post is not only for studying software, but also for improving my English.

I would appreciate any advice on my English, as well as any technical comments.

Thank you in advance.

INTRODUCTION

When I searched for information about Docker, I came across some Japanese websites that stated,

"Docker is only compatible with Linux OS."

This sentence confused me because I have successfully run Docker on my PC which uses Windows.

So, I wonder if many people were mistaken about Docker.

Initially I did not understand how Docker worked.

To clear up my confusion, I decided to summarize and post about the question of Docker's compatibility with Windows.

In my post, I explained how Docker works on Windows.

BODY

In the INTRODUCTION, I mentioned that the sentence confused me.

"Docker is only compatible with Linux OS."

I founded that some people in Japan share the same confusion as me, as seen on this Japanese website "Qiita".

https://qiita.com/AA_RU/items/7cce697eea822471840f

What does "Docker is only compatible with Linux OS." mean?

After examinig the issue in detail, I discovered that this is true.

According to the Official Docker Documentation,

Docker is written in the Go programming language and takes advantage of several features of the Linux kernel to deliver its functionality.

Therefore, it is accurate to say that Docker is primarily designed for use with Linux OS.

So, what does this mean for Windows users who want to use Docker ?

Enabling Docker on Windows using "Hypervisor" and "WSL"

Two technologies that enable Docker on Windows are Hypervisor and WSL.

  1. Hypervisor
  2. WSL

I will explain each of them.

Hypervisor

According to VMware,

A hypervisor, also known as a virtual machine monitor or VMM, is software that creates and runs virtual machines (VMs).(*snip*)There are two main hypervisor types, referred to as “Type 1” (or “bare metal”) and “Type 2” (or “hosted”). A type 1 hypervisor acts like a lightweight operating system and runs directly on the host’s hardware, while a type 2 hypervisor runs as a software layer on an operating system, like other computer programs.

Image diagram which I think about Hypervisor,

Type of Hypervisor

Their difference point is location of Hypervisor.

Bare Metal hypervisor is generally used when you activate Docker on a Windows PC.

In this, the important point is "runs directly on the host’s hardware".

By running directly on the host’s hardware, you can construct multiple OS in your PC.

However, in this situation, Linux and Docker cannot be activated because the Windows PC does not have the Linux Kernel.

To enable Docker on Windows, you need to use WSL.

hypervi

※======================
"Hypervisor" is a general term that refers to a software program that creates and manages virtual machines. "Hyper-V" is Microsoft's specific hypervisor technology. There are other hypervisors available such as "vSphere" in VMware and "KVM".
※======================

WSL

According to Microsoft,

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

In other words,
WSL is developper tool which enable to set up Linux enviroment on Windows PC.

WSL has 2 version. WSL1 and WSL2.

WSL1 behaves like the Linux kernel, while WSL2 is mostly the same as the Linux Kernel.

I think WSL2 is mainstream now, so I will proceed with the premise that WSL = WSL2.

By installing WSL2, Windows PC have Linux Kernel and can construct Linux OS on Hypervisor.

※Ubuntu is automatically installed by default when you install WSL2.

wsl2

Conclusion

The final result will look like the illustration below.

By using a hypervisor, you can create a foundation that can boot a different OS, and by installing WSL you can run Linux.

This will create an environment where Docker can run.
final images

Top comments (0)