How Docker works on windows
Tags: docker, begineer, wsl
Published: 2023-05-03 07:55:49

---
title: How Docker works on windows
published: true
description: How Docker works on windows
tags: Docker, Begineer, wsl
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3vmgqc08iesea0tzpf5.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-04-30 09:36 +0000
---
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." 

<br>

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.

<br>

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.

<br>

## 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

<br>
<br>


### 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](https://docs.docker.com/get-started/overview/#:~:text=Docker%20is%20written%20in%20the%20Go%20programming%20language%20and%20takes%20advantage%20of%20several%20features%20of%20the%20Linux%20kernel%20to%20deliver%20its%20functionality.),  
>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 ?

<br>

### 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.

<br>

#### Hypervisor
According to [VMware](https://www.vmware.com/topics/glossary/content/hypervisor.html?resource=cat-1299087558#cat-1299087558), 
>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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1flgcxhcy9auf3mx4ndd.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cpzawdqwdgixlj5qctb.png)

※======================
"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".
※======================  


<br>

#### WSL

According to [Microsoft](https://learn.microsoft.com/en-us/windows/wsl/about),
>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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yewqnw1id6be44x1dphi.png)

<br>

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrr5bti960bks2xvdmsn.png)