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

  • Context: Python 
  • Thread starter Thread starter fog37
  • Start date Start date
  • Tags Tags
    Windows
Click For Summary
SUMMARY

This discussion clarifies the operational differences between Docker containers and virtual machines (VMs) on Windows. Docker on Windows utilizes both Hyper-V and WSL 2, with WSL 2 functioning as a lightweight VM that simulates a Linux environment. The Dockerfile command "FROM python:3" indicates the use of a parent image that includes the Python interpreter and the Alpine Linux distribution. Ultimately, while Docker containers are lightweight and efficient, running them on Windows necessitates a VM layer, which can create confusion regarding their containerized nature.

PREREQUISITES
  • Understanding of Docker architecture and its components
  • Familiarity with Hyper-V as a hypervisor technology
  • Knowledge of Windows Subsystem for Linux (WSL 2) functionality
  • Basic comprehension of Dockerfile syntax and image management
NEXT STEPS
  • Explore Docker's integration with Hyper-V and WSL 2 on Windows
  • Learn about creating and managing Dockerfiles for application deployment
  • Investigate the performance implications of using WSL 2 for Docker containers
  • Study the differences between Docker containers and traditional virtual machines
USEFUL FOR

Developers working with Docker on Windows, system administrators managing hybrid environments, and anyone interested in containerization technologies and their implementation on Windows platforms.

fog37
Messages
1,566
Reaction score
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
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.
 
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.
 


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

Similar threads

  • · Replies 1 ·
Replies
1
Views
5K
Replies
6
Views
3K
Replies
13
Views
4K
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K