# Why does Discourse have to use Docker?

**URL:** <https://meta.discourse.org/t/why-does-discourse-have-to-use-docker/26041>\
**Category:** Self-hosting\
**Tags:** docker\
**Created:** [2015 年 3 月 5 日午後 7:59 UTC](https://meta.discourse.org/t/why-does-discourse-have-to-use-docker/26041 "2015-03-05T19:59:01Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2015 年 3 月 6 日午前 8:33 UTC](https://meta.discourse.org/t/why-does-discourse-have-to-use-docker/26041/8 "2015-03-06T08:33:07Z")

</div>

Unlike a traditional virtual machine, LXC containers (like Docker) share the OS with the host. So they use a tiny fraction of the resources.

 ![](https://global.discourse-cdn.com/meta/original/3X/1/f/1f125af1e85c78f796bd89cd5c56c18321656fb5.png) 

[http://sp.parallels.com/fileadmin/media/hcap/pcs/documents/ParCloudStorage\_Mini\_WP\_EN\_042014.pdf](http://sp.parallels.com/fileadmin/media/hcap/pcs/documents/ParCloudStorage_Mini_WP_EN_042014.pdf)

> On the other hand, container virtualization (shown in figure 2), is virtualization at the operating system level, instead of the hardware level. So each of the guest operating systems shares the same kernel, and sometimes parts of the operating system, with the host. This enhanced sharing gives containers a great advantage in that they are leaner and smaller than hypervisor guests, simply because they’re sharing much more of the pieces with the host. It also gives them the huge advantage that the guest kernel is much more efficient about sharing resources between containers, because it sees the containers as simply resources to be managed.
> 
> An example: Container 1 and Container 2 open the same file, the host kernel opens the file and puts pages from it into the kernel page cache. These pages are then handed out to Container 1 and Container 2 as they are needed, and if both want to read the same position, they both get the same page. In the case of VM1 and VM2 doing the same thing, the host opens the file (creating pages in the host page cache) but then each of the kernels in VM1 and VM2 does the same thing, meaning if VM1 and VM2 read the same file, there are now three separate pages (one in the page caches of the host, VM1 and VM2 kernels) simply because they cannot share the page in the same way a container can. This advanced sharing of containers means that the density (number of containers of Virtual Machines you can run on the system) is up to three times higher in the container case as with the Hypervisor case.

The downside is that the isolation is not as complete, but performance and resource wise LXC containers are 3x or more efficient than virtual machines.

---

_[View the full topic](https://meta.discourse.org/t/why-does-discourse-have-to-use-docker/26041)._
