0

What is the difference between running a Docker container with Debian (eg. https://hub.docker.com/_/debian/) and then running a virtual machine with Debian? And why is it still an advantage if any?

I'm curious to know the details since the concept of Docker is to not include the OS layer and therefore make it lightweight...! But how come there is a docker image with the Debian operating system (!) when containers do not run an operating system?! How is it that I can still have all the Linux OS features in a Linux container (bash, filesystem, file structure, package manager, cron jobs etc etc) if I don't have that OS?!

Note: I'm using Docker Desktop for Windows.

2 Answers 2

2

With an VM you have a complete machine with all the overhead like filesystem, bash.... With Docker, you use all of that from the "host". Only what is really different is sort of duplicated.

makes sense?

here is an picture: docker vs VM

To make it a bit clearer:

In the docker container are only the extra bins/libs needed for that particular application.

Everything else is provided by the host-os.

That makes the up and down of the app much faster and the overall systemload is much less, since you only have one os running.

With an VM, on the other hand, you have a whole os running. Most of that is not needed.

5
  • I understand it conceptually - maybe it's just that I have a hard time understanding why I have all the OS features in a Linux container that I normally have in a VM (bash, filesystem, file structure, cron jobs etc etc) - or is my confusion simply because I'm using Docker Desktop for Windows which runs a Linux VM for all my containers and that is the common OS for all of them? Commented Jun 3, 2021 at 17:03
  • For docker: There is no need* to run a VM when running on a linux operating system.
    – Erich
    Commented Jun 4, 2021 at 9:36
  • *Should you run outside of a VM is a security question. Likewise, should I run with this pair of scissors is a health question.
    – Erich
    Commented Jun 4, 2021 at 9:36
  • @TheStoryCoder: probably. Docker is using Linux underneath, that's why, yes.
    – David
    Commented Jun 4, 2021 at 11:48
  • To run an app, you need the app runner, let's say that's Nodejs. On the container, you have the code and NodeJS to run your application, there is no need for additional software. That way you could spin up multiple containers that will run and use up fewer resources. Now if you spin up multiple VMs with all the OS features that will take more resources and you won't be able to scale as easily as containers. Commented Aug 25 at 8:27
0

Docker

Docker is a lightweight container that runs the host's files in isolation. It uses the kernel from the host but the filesystem from the guest. So for Debian, you get all of Debian's commands (like apt). For Arch, you end up with pacman as your package manager - regardless of what host you are running.

Because you're still using the kernel from the host, you can't change kernel settings without special permission from Docker. Because you're still running on your real machine, the hardware will be what you would see on the host, though you may not be able to access all of it without special permission from Docker.

VM

A virtual machine emulates all of the hardware found on a real machine. Your virtual machine be created using any hardware for which emulation exists. You're running the kernel in the guest on top of the virtualized hardware. A special layer is needed to connect any hardware or expose any files from the host.

Docker for Windows

As you mentioned in a comment, Docker on Windows requires a Linux installation using Windows Subsystem for Linux (WSL), which is essentially a special virtual machine. Docker runs on that WSL layer when in "Linux mode". Docker for Windows also has a "Windows mode", which can run Windows containers without the need for a Linux layer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.