{"id":365532,"date":"2021-11-11T16:00:23","date_gmt":"2021-11-11T13:00:23","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/"},"modified":"2021-11-11T16:00:23","modified_gmt":"2021-11-11T13:00:23","slug":"what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/","title":{"rendered":"#What are Docker Storage Drivers and Which Should You Use? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6aefd67dbf5a6\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6aefd67dbf5a6\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#What_Are_Storage_Drivers_For\" >What Are Storage Drivers For?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#What_Happens_When_You_Start_a_Container\" >What Happens When You Start a Container?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#Available_Storage_Drivers\" >Available Storage Drivers<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#overlay2\" >overlay2<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#btrfs_and_zfs\" >btrfs and zfs<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#fuse-overlayfs\" >fuse-overlayfs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#vfs\" >vfs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#devicemapper\" >devicemapper<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-docker-storage-drivers-and-which-should-you-use-cloudsavvy-it\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What are Docker Storage Drivers and Which Should You Use? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-9034\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/6dc7b5a0.jpeg?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/6dc7b5a0.jpeg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/6dc7b5a0.jpeg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1602\" height=\"902\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Docker storage drivers control how images and containers are stored on your filesystem. They\u2019re the mechanism that lets you create images, start containers, and modify writable layers. Here are the differences between each driver and the situations where they should be used.<\/p>\n<h2 id=\"what-are-storage-drivers-for\"><span class=\"ez-toc-section\" id=\"What_Are_Storage_Drivers_For\"><\/span>What Are Storage Drivers For?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The active storage driver determines how Docker manages your images and containers. The available drivers implement different strategies for handling image layers. They\u2019ll have unique performance characteristics depending on the storage scenario at hand.<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.docker.com\/storage\/storagedriver\">Storage drivers<\/a> are intrinsically linked to a container\u2019s \u201cwritable layer.\u201d This term refers to the topmost level of a container\u2019s filesystem which you can modify by running commands, writing files, and adding software at runtime.<\/p>\n<p>Although persistent Docker container data should always be stored in volumes, changes to the container\u2019s own filesystem are often inevitable. You might be writing temporary files, storing environment variables into a config file, or caching data for later reference.<\/p>\n<p>These operations all result in the running container\u2019s filesystem deviating from the one defined by its image. Your choice of storage driver handles the discrepancy and <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>lies the difference.<\/p>\n<h2 id=\"what-happens-when-you-start-a-container\"><span class=\"ez-toc-section\" id=\"What_Happens_When_You_Start_a_Container\"><\/span>What Happens When You Start a Container?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When a new container starts, Docker first pulls the image layers created by building its Dockerfile. The layers get stored on your host machine so you don\u2019t need to pull the image again until you want to fetch updates. As part of the pull process, Docker will identify and reuse layers it already has, avoiding redundant downloads.<\/p>\n<p>Once the image layers are available, Docker will launch the container and add an extra layer on top. This is the writable layer that the container can modify. All lower layers are immutable and derived from their Dockerfile definitions.<\/p>\n<figure style=\"width: 769px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14580 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/10\/fb8d2308.jpg?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Diagram showing how Docker writable layers work\" width=\"769\" height=\"475\" data-crediturl=\"https:\/\/docs.docker.com\/storage\/storagedriver\/\" data-credittext=\"Docker.com\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.docker.com\/storage\/storagedriver\/\">Docker.com<\/a><\/span><\/figcaption><\/figure>\n<p>The writable layer works well with few overheads when you\u2019re simply adding files to a container\u2019s filesystem. They end up in the writable layer, at the top of the stack. Modifications to existing files are more troublesome though: they exist in lower read-only layers but now need to be written to.<\/p>\n<p>Docker\u2019s approach is to \u201ccopy-on-write,\u201d meaning the file is copied out of its original layer and into the writable layer at the point of modification. This is an I\/O-intensive operation which can lead to performance degradation.<\/p>\n<p>The differing storage drivers <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.docker.com\/storage\/storagedriver\/#copying-makes-containers-efficient\">are responsible for<\/a> implementing copy-on-write support. Each driver offers unique trade-offs between performance and disk usage efficiency.<\/p>\n<h2 id=\"available-storage-drivers\"><span class=\"ez-toc-section\" id=\"Available_Storage_Drivers\"><\/span>Available Storage Drivers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Docker uses a pluggable storage driver architecture and provides several options by default. Storage drivers don\u2019t affect individual images or containers \u2013 you can run any Docker image irrespective of the selected driver.<\/p>\n<p>The active storage driver is a runtime-level setting that\u2019s defined in the Docker daemon\u2019s configuration file. Some storage drivers require special filesystem provisioning before you can use them. You then add your selected storage driver to <code>\/etc\/docker\/daemon.json<\/code>:<\/p>\n<pre>{&#13;\n    \"storage-driver\": \"overlay2\"&#13;\n}<\/pre>\n<p>You can check your current driver by running <code>docker info | grep \"Storage Driver\"<\/code>. On most modern systems, it\u2019ll default to <code>overlay2<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14579\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/10\/9320b40c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"690\" height=\"79\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Here\u2019s a rundown of the options you can choose between.<\/p>\n<h3 id=\"overlay2\"><span class=\"ez-toc-section\" id=\"overlay2\"><\/span>overlay2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code>overlay2<\/code> driver is now the default on all actively supported Linux distributions. It requires an <code>ext4<\/code> or <code>xfs<\/code> backing filesystem.<\/p>\n<p><code>overlay2<\/code> offers a good balance between performance and efficiency for copy-on-write operations. When a copy-on-write is needed, the driver searches through the image\u2019s layers to find the right file, starting from the topmost layer. Results are cached to accelerate the process next time.<\/p>\n<p>Once the file\u2019s been found, it\u2019s copied up to the container\u2019s writable layer. The copy is then modified with the changes requested by the container. From here on, the container sees only the new copied version of the file. The original in the lower image layer becomes opaque to the container.<\/p>\n<p><code>overlay2<\/code> operates at the file level as opposed to the block level. This enhances performance by maximizing memory use efficiency but can result in larger writable layers when many changes are made.<\/p>\n<p>Alternatives to this driver include <code>aufs<\/code> and the older <code>overlay<\/code>. Neither of these are recommended for use on modern Linux distributions where <code>overlay2<\/code> is supported.<\/p>\n<h2 id=\"btrfs-and-zfs\"><span class=\"ez-toc-section\" id=\"btrfs_and_zfs\"><\/span>btrfs and zfs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>These two drivers work at the block level and are ideal for write-intensive operations. They each require their respective backing filesystem.<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.docker.com\/storage\/storagedriver\/btrfs-driver\/#how-the-btrfs-storage-driver-works\">Use of these drivers<\/a> results in your <code>\/var\/lib\/docker<\/code> directory being stored on a <code>btrfs<\/code> or <code>zfs<\/code> volume. Each image layer gets its own directory in the <code>subvolumes<\/code> folder. Space is allocated to directories on-demand as it\u2019s needed, keeping disk utilization low until copy-on-write operations occur.<\/p>\n<p>Image base layers are stored as subvolumes on the filesystem. Other layers become snapshots, containing only the differences they introduce. Writable layer modifications are handled at the block level, adding another space-efficient snapshot.<\/p>\n<p>You can create snapshots of subvolumes and other snapshots at any time. These snapshots continue to share unchanged data, minimizing overall storage consumption.<\/p>\n<p>Using one of these drivers can you a give better experience for heavily write-intensive containers. If you\u2019re writing a lot of temporary files or caching many operations on-disk, <code>btrfs<\/code> or <code>zfs<\/code> can out-perform <code>overlay2<\/code>. The one you should use depends on your backing filesystem \u2013 <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>ly <code>zfs<\/code> is preferred as a more modern alternative to <code>btrfs<\/code>.<\/p>\n<h3 id=\"fuse-overlayfs\"><span class=\"ez-toc-section\" id=\"fuse-overlayfs\"><\/span>fuse-overlayfs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This storage driver provides a way to run Docker in rootless mode on a machine that lacks support for the <code>overlay2<\/code> driver. However, as all currently targeted Linux distributions now work with <code>overlay2<\/code>, <code>fuse-overlayfs<\/code> is no longer needed or recommended.<\/p>\n<p>This <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/containers\/fuse-overlayfs\">driver works<\/a> by implementing an overlay filesystem using FUSE. As a user-space file system, it works in rootless mode but incurs performance penalties compared to a kernel-level storage system.<\/p>\n<h3 id=\"vfs\"><span class=\"ez-toc-section\" id=\"vfs\"><\/span>vfs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code>vfs<\/code> driver is included for test purposes only and shouldn\u2019t be used in production. The performance of this driver is documented as poor.<\/p>\n<p><code>vfs<\/code> can be useful in some special scenarios as it does not use copy-on-write. Instead each layer gets its own on-disk directory. When a file needs to move between layers, it\u2019s simply copied into a new directory.<\/p>\n<p>Consequently <code>vfs<\/code> works with all filesystems and benefits from simplicity and ease of inspection. It suffers from being I\/O-intensive and prone to causing high disk usage as each file modification triggers a full copy from the source layer.<\/p>\n<h3 id=\"devicemapper\"><span class=\"ez-toc-section\" id=\"devicemapper\"><\/span>devicemapper<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This was once the recommended driver for CentOS and RHEL but it has lost its place to <code>overlay2<\/code> in more recent kernel releases. This driver required a <code>direct-lvm<\/code> backing filesystem. <code>devicemapper<\/code> should no longer be used \u2013 it\u2019s deprecated and will be removed entirely in the future.<\/p>\n<h2 id=\"summary\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Docker\u2019s storage drivers are used to manage image layers and the writable portion of a container\u2019s filesystem. Although changes to container filesystems are lost when the container stops, they still need to be persisted while the container running. It\u2019s the storage driver that provides this mechanism.<\/p>\n<p>Each driver possesses a different set of optimizations that makes it more or less suitable for different scenarios. Nowadays <code>overlay2<\/code> is the default driver and the recommended option for most workloads, although alternative options like <code>btrfs<\/code>, <code>zfs<\/code>, and <code>fuse-overlayfs<\/code> have some more advanced features and may be required in certain cases.\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/14578\/what-are-docker-storage-drivers-and-which-should-you-use\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What are Docker Storage Drivers and Which Should You Use? \u2013 CloudSavvy IT&#8221; Docker storage drivers control how images and containers are stored on your filesystem. They\u2019re the mechanism that lets you create images, start containers, and modify writable layers. Here are the differences between each driver and the situations where they should be used&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":365533,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/01\/6dc7b5a0.jpeg","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-365532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/365532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=365532"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/365532\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/365533"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=365532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=365532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=365532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}