I have Windows 10 Enterprise Version and I have installed Docker Desktop, enabled WSL2 backend, and downloaded and installed the Linux kernel update package.
I am learning Docker and I have some doubts about how Docker works behind the scenes.
- I have drawn a basic architecture diagram of Docker on windows with WSL2, is this correct?
- Whenever we create a new Linux container it gets created in the same lightweight utility VM provided by WSL2?
- And if we create a windows container it gets created on windows os?
- Can these containers access windows and Linux kernels both when
required? Like when running a java app in a
Linux container
it requires windows kernel, right?
- So, by default docker runs Linux containers, when do we need windows containers? I can containerize a java application by using openjdk:8, but I am not able to pull windows nanoserver image when I run Linux containers, it works only when I switch to Windows Containers. What is going on here? Does this mean the openjdk:8 image is a Linux image(i do not know how to say it), and windows nanoserver a windows image?
- How Linux Containers can run my java application? It must need the windows kernel, right?
- If the docker containers reside within the lightweight utility VM created by WSL2, can it access both the Linux kernel that it ships with and the Windows Kernel?
I have the default Linux container
mode and I tried these two
commands.
- docker run --platform=linux -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
- docker pull mcr.microsoft.com/windows/nanoserver:1903
The first one worked for the second one I got the following error.
1903: Pulling from windows/nanoserver no matching manifest for Linux/amd64 in the manifest list entries
But when I switch to windows containers
it works.
- So what is the difference between my java app on openjdk:8 image and windows nanoserver?
- Do these not require windows kernel to run?
- How is the java thing running on Linux containers then?
Edits :- Need more clarification on this- Copying the question from comment section.
And one more thing, the containers do not access windows and Linux kernels simultaneously in WSL2 right? After all they are just isolated spaces in an OS, so either they can be in windows or Linux? Please correct me if I am wrong. The Linux images are built in such a way that it has everything to run my java and as java is a cross platform language so it can run on Linux kernel, is this the concept?
About the architecture diagram that I have made here- the containers(isolated processes in an operating system with app files) , in case of Linux containers all of them(multiple containers) runs on the same WSL2 VM, right?