Docker containers in Windows "look" like VMs...

  • Python
  • Thread starter fog37
  • Start date
  • Tags
    Windows
In summary, Docker containers on Windows are designed to mimic the functionalities of virtual machines (VMs) while maintaining the lightweight and efficient nature of containerization. This approach allows developers to utilize the benefits of both technologies, enabling the deployment of applications in isolated environments without the overhead associated with traditional VMs. The integration of Docker with Windows facilitates seamless management and orchestration of containers, providing a flexible solution for application development and deployment.
  • #1
fog37
1,569
108
Hello,

I am trying to better understand how Docker works under the hood in Windows...I get the difference between virtual machines (guest OS on top of a host OS) and containers (which work with the host OS)...The Docker desktop installation process seems to automatically install both Hyper V and WSL 2 (which is different from WSL1...Hyper V a type of lightweight hypervisor to run and manage virtual machines and WSL2 is really a Linux OS virtual machine... If so, then running Docker in Windows seems to be like running a virtual machine and not a container..

IF the Dockerfile first line is FROM python :3, it means that we are instructing the docker engine to go on Docker hub and downloaed a Docker parent image containing the interpreter python as well as the Linux distribution Alpine....I get Docker is truly a linux application. Now we have both the Alpine Linux distribution and WSL2 which seem to be two Linux operating systems...Again, that looks more like a virtual machine than a container: we have Windows (our host OS), Alpine, and WSL2...

Thank you!
 
Technology news on Phys.org
  • #2
Docker is a linux technology that runs on windows and macos. On Linux, it takes advantage of some Linux security protections to run code in a sort of sandbox using the same OS. This makes Docker containers very light-weight and reduces system resource usage on a Linux host.

When running on Windows there has to be a VM to run Docker inside. Windows provides the WSL subsystem for that and it is a VM that looks like a linux environment to Docker. It was quite "inspired" by MS to offer this but I guess they saw the writing on the wall with developers bouncing between the two environments. I know they resisted this approach for a long time forcing people to have two machines, or log into a linux machine or use dual boot...

https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux

One thing that I found cool was that the MS VS code editor works in both environments via a web service that runs inside the WSL environment and does the CRLF conversion seamlessly between them. It allows developers to span the environments much more easily.
 
  • #3
It is probably worth pointing out that the distinction between "sandbox' and "full virtual machine" is also a matter of degree. The CPU is still executing the instructions like it always did.
 
  • #4


I use Docker to run a specific Home Assistant Linux 'environment' on a general Linux server that handles other networking and processing capabilities for the programs running inside the Docker 'environment'.
 
  • #5
Vanadium 50 said:
It is probably worth pointing out that the distinction between "sandbox' and "full virtual machine" is also a matter of degree. The CPU is still executing the instructions like it always did.
Yes, this brings up an interesting scenario. Commodore 64 family of machines are emulated in the VICE application. Its like a VM that executes 6502 code on any machine hosting VICE. That means that the 6502 code is "translated" in equivalent machine code of the host machine to run. They even simulate the Commodore address space for peeks and pokes.

I would consider VICE a full blown VM vs something like WSL that runs linux on Windows where the opcodes of the image are the same as the host ie you wouldn't install an Apple M2 linux image on WSL if it is running on an Intel processor since the opcodes are different.
 

FAQ: Docker containers in Windows "look" like VMs...

1. What are Docker containers, and how do they differ from virtual machines (VMs)?

Docker containers are lightweight, portable, and self-sufficient units that package an application and its dependencies together. Unlike virtual machines, which require a full operating system to run, containers share the host OS kernel and are more efficient in terms of resource utilization. This allows containers to start up quickly and use less memory compared to VMs, which run separate OS instances.

2. Can Docker containers run on Windows, and how do they compare to Linux containers?

Yes, Docker containers can run on Windows. Docker Desktop for Windows allows users to run both Windows containers and Linux containers using a lightweight VM called WSL 2 (Windows Subsystem for Linux). While Windows containers are optimized for Windows applications, Linux containers are typically used for applications that are designed to run on Linux. The primary difference lies in the underlying OS and the available system calls.

3. Do Docker containers provide the same level of isolation as virtual machines?

While Docker containers offer a degree of isolation through namespaces and control groups, they do not provide the same level of isolation as virtual machines. VMs are fully isolated from each other and the host system, with their own kernel and OS. Containers, on the other hand, share the host OS kernel, which can lead to potential security concerns if not managed properly. However, containers are still considered secure for most applications, especially when best practices are followed.

4. How can I manage Docker containers on a Windows system?

You can manage Docker containers on a Windows system using Docker Desktop, which provides a graphical user interface as well as command-line tools. The Docker CLI (Command Line Interface) allows you to build, run, stop, and manage containers using commands. Additionally, Docker Compose can be used to define and run multi-container applications using a simple YAML file.

5. Are there any performance implications when using Docker containers on Windows?

There can be performance implications when using Docker containers on Windows, particularly when running Linux containers. The use of WSL 2 introduces a lightweight VM layer, which may add some overhead compared to running containers on a native Linux system. However, for many applications, this overhead is minimal and often outweighed by the benefits of using containers, such as ease of deployment and scalability.

Back
Top