<p>With an VM you have a complete machine with all the overhead like filesystem, bash....
With Docker, you use all of that from the &quot;host&quot;. Only what is really different is sort of duplicated.</p>
<p>makes sense?</p>
<p>here is an picture:
<a href="https://geekflare.com/wp-content/uploads/2019/09/traditional-vs-new-gen.png" rel="nofollow noreferrer">docker vs VM</a></p>
<p>To make it a bit clearer:</p>
<p>In the docker container are only the extra bins/libs needed for that particular application.</p>
<p>Everything else is provided by the host-os.</p>
<p>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.</p>
<p>With an VM, on the other hand, you have a whole os running. Most of that is not needed.</p>

CC BY-SA 4.0
2021-06-03T17:03:24.183Z
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?
TheStoryCoder
CC BY-SA 4.0
2021-06-04T09:36:12.613Z
For docker: There is no need* to run a VM when running on a linux operating system.
Erich
CC BY-SA 4.0
2021-06-04T09:36:50.320Z
*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
CC BY-SA 4.0
2021-06-04T11:48:25.907Z
@TheStoryCoder: probably. Docker is using Linux underneath, that's why, yes.
David
CC BY-SA 4.0
2024-08-25T08:27:12.820Z
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.
Kristian Kanchev
CC BY-SA 4.0
2021-06-03T10:43:54.313Z
2021-06-03T10:58:12.530Z
2021-06-03T10:58:12.530Z
David
<h1>Docker</h1>
<p>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 <code>apt</code>). For Arch, you end up with <code>pacman</code> as your package manager - regardless of what host you are running.</p>
<p>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.</p>
<h1>VM</h1>
<p>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.</p>
<h1>Docker for Windows</h1>
<p>As you mentioned in a comment, Docker on Windows requires a Linux installation using <a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux" rel="nofollow noreferrer">Windows Subsystem for Linux (WSL)</a>, which is essentially a special virtual machine. Docker runs on that WSL layer when in &quot;Linux mode&quot;. Docker for Windows also has a &quot;Windows mode&quot;, which can run Windows containers without the need for a Linux layer</p>

CC BY-SA 4.0
2024-08-25T01:53:59.293Z
2024-08-25T01:53:59.293Z
Codebling
<p>What is the difference between running a Docker container with Debian (eg. <a href="https://hub.docker.com/_/debian/" rel="nofollow noreferrer">https://hub.docker.com/_/debian/</a>) and then running a virtual machine with Debian? And why is it still an advantage if any?</p>
<p>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 <em>operating system</em> (!) 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?!</p>
<p>Note: I'm using <em>Docker Desktop for Windows</em>.</p>

<docker><containers><linux>
Difference between Docker container with Debian vs VM with Debian?
TheStoryCoder
# Difference between Docker container with Debian vs VM with Debian?

(Asked by: username_0 on 2021-06-03)

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

**Tags:** docker, containers, linux


---

## 2 answers

### Answer by username_1 on 2021-06-03. Score: 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](https://geekflare.com/wp-content/uploads/2019/09/traditional-vs-new-gen.png)

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.

> **Comments:**
> **username_0**: 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?  
> **username_2**: For docker: There is no need* to run a VM when running on a linux operating system.  
> **username_2**: *Should you run outside of a VM is a security question.  Likewise, should I run with this pair of scissors is a health question.  
> **username_1**: @username_0: probably. Docker is using Linux underneath, that's why, yes.  
> **username_3**: 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.  

---

### Answer by username_4 on 2024-08-25. Score: 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)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), 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


---

