kernel.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. .. _kernel:
  2. Kernel Requirements
  3. ===================
  4. The officially supported kernel is the one recommended by the
  5. :ref:`ubuntu_linux` installation path. It is the one that most developers
  6. will use, and the one that receives the most attention from the core
  7. contributors. If you decide to go with a different kernel and hit a bug,
  8. please try to reproduce it with the official kernels first.
  9. If for some reason you cannot or do not want to use the "official" kernels,
  10. here is some technical background about the features (both optional and
  11. mandatory) that docker needs to run successfully.
  12. In short, you need kernel version 3.8 (or above), compiled to include
  13. `AUFS support <http://aufs.sourceforge.net/>`_. Of course, you need to
  14. enable cgroups and namespaces.
  15. Namespaces and Cgroups
  16. ----------------------
  17. You need to enable namespaces and cgroups, to the extend of what is needed
  18. to run LXC containers. Technically, while namespaces have been introduced
  19. in the early 2.6 kernels, we do not advise to try any kernel before 2.6.32
  20. to run LXC containers. Note that 2.6.32 has some documented issues regarding
  21. network namespace setup and teardown; those issues are not a risk if you
  22. run containers in a private environment, but can lead to denial-of-service
  23. attacks if you want to run untrusted code in your containers. For more details,
  24. see `[LP#720095 <https://bugs.launchpad.net/ubuntu/+source/linux/+bug/720095>`_.
  25. Kernels 2.6.38, and every version since 3.2, have been deployed successfully
  26. to run containerized production workloads. Feature-wise, there is no huge
  27. improvement between 2.6.38 and up to 3.6 (as far as docker is concerned!).
  28. Starting with version 3.7, the kernel has basic support for
  29. `Checkpoint/Restore In Userspace <http://criu.org/>`_, which is not used by
  30. docker at this point, but allows to suspend the state of a container to
  31. disk and resume it later.
  32. Version 3.8 provides improvements in stability, which are deemed necessary
  33. for the operation of docker. Versions 3.2 to 3.5 have been shown to
  34. exhibit a reproducible bug (for more details, see issue
  35. `#407 <https://github.com/dotcloud/docker/issues/407>`_).
  36. Version 3.8 also brings better support for the
  37. `setns() syscall <http://lwn.net/Articles/531381/>`_ -- but this should not
  38. be a concern since docker does not leverage on this feature for now.
  39. If you want a technical overview about those concepts, you might
  40. want to check those articles on dotCloud's blog:
  41. `about namespaces <http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part>`_
  42. and `about cgroups <http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-24-c>`_.
  43. Important Note About Pre-3.8 Kernels
  44. ------------------------------------
  45. As mentioned above, kernels before 3.8 are not stable when used with docker.
  46. In some circumstances, you will experience kernel "oopses", or even crashes.
  47. The symptoms include:
  48. - a container being killed in the middle of an operation (e.g. an ``apt-get``
  49. command doesn't complete);
  50. - kernel messages including mentioning calls to ``mntput`` or
  51. ``d_hash_and_lookup``;
  52. - kernel crash causing the machine to freeze for a few minutes, or even
  53. completely.
  54. While it is still possible to use older kernels for development, it is
  55. really not advised to do so.
  56. Docker checks the kernel version when it starts, and emits a warning if it
  57. detects something older than 3.8.
  58. See issue `#407 <https://github.com/dotcloud/docker/issues/407>`_ for details.
  59. Extra Cgroup Controllers
  60. ------------------------
  61. Most control groups can be enabled or disabled individually. For instance,
  62. you can decide that you do not want to compile support for the CPU or memory
  63. controller. In some cases, the feature can be enabled or disabled at boot
  64. time. It is worth mentioning that some distributions (like Debian) disable
  65. "expensive" features, like the memory controller, because they can have
  66. a significant performance impact.
  67. In the specific case of the memory cgroup, docker will detect if the cgroup
  68. is available or not. If it's not, it will print a warning, and it won't
  69. use the feature. If you want to enable that feature -- read on!
  70. Memory and Swap Accounting on Debian/Ubuntu
  71. -------------------------------------------
  72. If you use Debian or Ubuntu kernels, and want to enable memory and swap
  73. accounting, you must add the following command-line parameters to your kernel::
  74. cgroup_enable=memory swapaccount
  75. On Debian or Ubuntu systems, if you use the default GRUB bootloader, you can
  76. add those parameters by editing ``/etc/default/grub`` and extending
  77. ``GRUB_CMDLINE_LINUX``. Look for the following line::
  78. GRUB_CMDLINE_LINUX=""
  79. And replace it by the following one::
  80. GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount"
  81. Then run ``update-grub``, and reboot.
  82. AUFS
  83. ----
  84. Docker currently relies on AUFS, an unioning filesystem.
  85. While AUFS is included in the kernels built by the Debian and Ubuntu
  86. distributions, is not part of the standard kernel. This means that if
  87. you decide to roll your own kernel, you will have to patch your
  88. kernel tree to add AUFS. The process is documented on
  89. `AUFS webpage <http://aufs.sourceforge.net/>`_.
  90. Note: the AUFS patch is fairly intrusive, but for the record, people have
  91. successfully applied GRSEC and AUFS together, to obtain hardened production
  92. kernels.
  93. If you want more information about that topic, there is an
  94. `article about AUFS on dotCloud's blog
  95. <http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-34-a>`_.
  96. BTRFS, ZFS, OverlayFS...
  97. ------------------------
  98. There is ongoing development on docker, to implement support for
  99. `BTRFS <http://en.wikipedia.org/wiki/Btrfs>`_
  100. (see github issue `#443 <https://github.com/dotcloud/docker/issues/443>`_).
  101. People have also showed interest for `ZFS <http://en.wikipedia.org/wiki/ZFS>`_
  102. (using e.g. `ZFS-on-Linux <http://zfsonlinux.org/>`_) and OverlayFS.
  103. The latter is functionally close to AUFS, and it might end up being included
  104. in the stock kernel; so it's a strong candidate!
  105. Would you like to `contribute
  106. <https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md>`_
  107. support for your favorite filesystem?