In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver?

  containers, docker, docker-desktop, linux

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?

enter image description here

  1. 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?
  2. How Linux Containers can run my java application? It must need the
    windows kernel, right?
  3. 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

  • docker run –platform=linux -d ubuntu /bin/sh -c "while true; do echo
    hello world; sleep 1; done"
  • docker pull

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.

  1. So what is the difference between my java app on openjdk:8 image and windows nanoserver?
  2. Do these not require windows kernel to run?
  3. How is the java thing running on Linux containers then?

Source: Docker Questions