添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
大鼻子的灌汤包
·
百度网盘 Mac 版 - Mac知道
·
4 月前
·
爱跑步的豆芽
·
ckeditor编辑的使用方法 - ...
·
4 月前
·
鬼畜的钢笔
·
Cmake 编译静库 动态库 ...
·
5 月前
·
玩足球的乒乓球
·
第四屆「我是自己的健康小主人」穗港澳中小學健 ...
·
6 月前
·
买醉的鸡蛋
·
为什么 Android ...
·
6 月前
·
link管理
›
Docker Volumes - Guide with Examples
https://spacelift.io/blog/docker-volumes
果断的沙滩裤
4 月前
</noscript><div id="__next"><div class="HelloBanner_helloBanner__aC6_Z HelloBanner_gradient__5bw3u"><div class="Container_root__MDMPu"><div class="HelloBanner_wrapper__LLKtO"><p class="Typography_styleBase__auQ0r Typography_styleS9__CStzO">Using generic CI/CD tools for your IaC automation? 🤖⚙️</p><p class="HelloBanner_cta__ARoxF Typography_styleBase__auQ0r Typography_styleS9__CStzO"><a href="https://learn.spacelift.io/lp/build-vs-buy-guide-to-scaling-iac" class="textLink TextLink_variantBase__QgaEW TextLink_variantUnderlined__npq3Z TextLink_styleLight__CAgeu" rel="noopener noreferrer" target="_blank">Download the Build vs Buy Guide →</a></p></div></div><button type="button" class="HelloBanner_closeButton__cN61l"><svg viewbox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M.836.836a.577.577 0 0 1 .817 0L6 5.183 10.348.836a.577.577 0 1 1 .816.816L6.817 6l4.348 4.347a.578.578 0 0 1-.817.817L6 6.817l-4.347 4.347a.577.577 0 1 1-.817-.817L5.184 6 .836 1.652a.577.577 0 0 1 0-.816Z"/></svg></button></div><header class="Navigation_header__6p4mC Navigation_bannerActive__7S0kk"><div class="Container_root__MDMPu"><nav class="Navigation_navigation__fmHy5"><div class="Navigation_mobileNavButton__xFMc8"><a class="mainMenuLink" href="/"><svg viewbox="0 0 169 53" fill="currentColor" xmlns="http://www.w3.org/2000/svg" alt="Spacelift logo" class="Navigation_logo__qgqmL"><path d="M159.284 24.832c-.596 4.453-2.41 7.11-4.979 7.288a5.679 5.679 0 0 1-2.513-.561 5.61 5.61 0 0 1-1.995-1.61 16.616 16.616 0 0 0 4.697-4.972 16.386 16.386 0 0 0 2.272-6.416 125.86 125.86 0 0 1-31.614 5.044 16.541 16.541 0 0 0 5.473 6.347 24.741 24.741 0 0 0-6.21 16.887h4.331a20.704 20.704 0 0 1 4.503-13.324 123.155 123.155 0 0 0-1.22 13.324h7.688s-1.41-5.754.886-5.759c2.295.005.885 5.76.885 5.76h7.689a120.955 120.955 0 0 0-1.118-12.592c.855.68 1.816 1.22 2.845 1.6a9.019 9.019 0 0 0 3.706.537 8.368 8.368 0 0 0 3.247-.922 8.273 8.273 0 0 0 2.605-2.125c1.617-1.907 2.665-4.58 3.115-7.947l-4.293-.56Z"/><path d="M141.347 23.485c15.272-2.453 27.161-7.42 26.556-11.093-.606-3.674-13.477-4.664-28.749-2.212-15.272 2.452-27.161 7.419-26.556 11.092.606 3.674 13.477 4.665 28.749 2.213Z" fill="url(#logo-saturn-head_svg__a)"/><path d="M7.77 37.783c-3.317-.442-3.587-1.046-3.587-1.732 0-.583.353-1.562 2.713-1.562 2.7 0 3.28 1.093 3.481 1.915l.037.148h3.504l-.02-.212c-.1-1.049-.885-4.469-6.833-4.469-4.731 0-6.41 2.402-6.41 4.46 0 2.503 1.916 3.87 6.217 4.43 3.676.442 3.98 1.202 3.98 2.01 0 1.184-1.084 1.785-3.222 1.785-2.24 0-3.6-.769-4.048-2.285l-.041-.14H0l.036.224c.499 3.098 3.195 4.875 7.397 4.875 4.414 0 6.947-1.717 6.947-4.71 0-1.991-.8-3.943-6.61-4.737ZM26.1 31.871c-2.778 0-4.338 1.135-5.204 2.266-.008-.684-.033-1.375-.081-1.709l-.024-.166h-3.479l.005.198c.028 1.169.028 2.366.028 3.536V53h3.556v-7.698a5.756 5.756 0 0 0 2.131 1.508 5.826 5.826 0 0 0 2.587.42c4.219 0 7.4-3.404 7.4-7.916 0-4.243-2.975-7.443-6.919-7.443Zm3.278 7.582c0 2.225-1.125 4.824-4.294 4.824-2.672 0-4.267-1.741-4.267-4.657 0-3.048 1.576-4.796 4.323-4.796 2.928 0 4.238 2.325 4.238 4.629ZM49.314 43.02v-5.993c0-3.42-2.28-5.156-6.777-5.156-5.698 0-6.617 3.302-6.748 4.72l-.02.212h3.537l.033-.153c.223-1.019.673-2.105 3.227-2.105 2.88 0 3.248 1.371 3.248 2.566v.503H42.65c-5.168 0-7.681 1.587-7.681 4.85 0 2.372 1.78 4.766 5.76 4.766 2.458 0 4.194-.648 5.175-1.926.013.465.06.928.142 1.385l.036.15h3.363l-.018-.21a62.81 62.81 0 0 1-.113-3.608Zm-10.846-.724c0-1.544 1.268-2.203 4.239-2.203 1.68 0 2.633 0 3.108.017v.318c0 2.684-1.474 4.044-4.38 4.044-1.885 0-2.967-.793-2.967-2.176ZM64.05 42.047a3.759 3.759 0 0 1-1.538 1.802c-.695.422-1.51.61-2.323.539-2.592 0-4.267-1.904-4.267-4.852 0-2.93 1.675-4.824 4.267-4.824a3.712 3.712 0 0 1 2.325.573 3.634 3.634 0 0 1 1.474 1.866l.047.126h3.5l-.035-.224c-.3-1.925-2.172-5.182-7.283-5.182a7.704 7.704 0 0 0-3.054.504 7.625 7.625 0 0 0-2.597 1.663 7.507 7.507 0 0 0-1.713 2.545 7.428 7.428 0 0 0-.543 3.009c0 4.64 3.093 7.637 7.88 7.637 3.784 0 6.537-1.889 7.363-5.052l.063-.242h-3.513l-.053.112ZM77.245 31.871c-4.573 0-7.767 3.175-7.767 7.721 0 3.802 2.42 7.637 7.824 7.637 5.01 0 6.796-2.893 7.415-4.617l.094-.259h-3.559l-.055.1c-.765 1.358-1.93 1.963-3.782 1.963a4.231 4.231 0 0 1-3.002-1.08 4.122 4.122 0 0 1-1.362-2.853h11.876v-.974c0-3.523-2.013-7.638-7.682-7.638Zm-.028 2.73c3.146 0 3.9 2.043 4.05 3.404h-8.15c.317-2.167 1.8-3.404 4.1-3.404ZM91.393 25.543h-3.557v21.296h3.557V25.543ZM97.212 25.599c-.357 0-.706.104-1.003.3a1.787 1.787 0 0 0-.665.8 1.762 1.762 0 0 0 .391 1.942 1.827 1.827 0 0 0 1.968.386 1.8 1.8 0 0 0 .81-.656 1.766 1.766 0 0 0-.224-2.25 1.82 1.82 0 0 0-1.277-.522ZM99.018 32.262H95.46v14.577h3.557V32.262ZM120.482 35.046v-2.785h-3.644v-4.46h-3.556v4.46h-5.595v-1.423c0-2.01.502-2.622 2.149-2.622.383-.002.766.033 1.142.106l.24.055v-2.846l-.145-.038a7.542 7.542 0 0 0-1.802-.173c-3.362 0-5.139 1.869-5.139 5.406v1.535h-2.628v2.785h2.628v11.792h3.555V35.046h5.595v7.585c0 3.088 1.227 4.347 4.235 4.347a7.83 7.83 0 0 0 2.435-.288l.135-.045v-2.609l-.238.05a7.251 7.251 0 0 1-1.316.107c-1.3 0-1.695-.469-1.695-2.008v-7.139h3.644ZM155.254 9.328a16.612 16.612 0 0 0-8.408-7.97 16.908 16.908 0 0 0-11.641-.602 16.675 16.675 0 0 0-9.206 7.06 16.312 16.312 0 0 0-2.286 11.282c.805 4.918 33.824-.111 32.98-5.263a16.348 16.348 0 0 0-1.439-4.507Z"/><defs><lineargradient id="logo-saturn-head_svg__a" x1="112.576" y1="16.832" x2="167.925" y2="16.832" gradientunits="userSpaceOnUse"><stop offset="0.082" stop-color="#82FFE8"/><stop offset="0.951" stop-color="#7C47FC"/></lineargradient></defs></svg></a><div class="Navigation_hamburgerBtnContainer__omIzG"><button class="HamburgerIconButton_menu__xASAs" aria-label="Main Menu"><svg viewbox="0 0 100 100"><path class="HamburgerIconButton_lineBase__OzKfJ HamburgerIconButton_firstLine__G52nf" d="M 20,29.000046 H 80.000231 C 80.000231,29.000046 94.498839,28.817352 94.532987,66.711331 94.543142,77.980673 90.966081,81.670246 85.259173,81.668997 79.552261,81.667751 75.000211,74.999942 75.000211,74.999942 L 25.000021,25.000058"/><path class="HamburgerIconButton_lineBase__OzKfJ HamburgerIconButton_secondLine__7q1vE" d="M 20,50 H 80"/><path class="HamburgerIconButton_lineBase__OzKfJ HamburgerIconButton_thirdLine__bkZq2" d="M 20,70.999954 H 80.000231 C 80.000231,70.999954 94.498839,71.182648 94.532987,33.288669 94.543142,22.019327 90.966081,18.329754 85.259173,18.331003 79.552261,18.332249 75.000211,25.000058 75.000211,25.000058 L 25.000021,74.999942"/></svg></button></div></div><div class="Navigation_menuWrapperMobile__FQKQH"><ul class="Navigation_list__iaD8Z"><li class="Dropdown_dropdown__2i61_"><button class="Dropdown_dropdownButton__zXS7Q"><span class="Dropdown_buttonText__FpAtZ Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Product</span><svg viewbox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="Dropdown_dropdownButtonIcon__xEJFh"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.299 9.869a.567.567 0 0 1 0-.802l3.734-3.734 3.734 3.734a.567.567 0 0 1-.801.802L8.033 6.936 5.1 9.87a.567.567 0 0 1-.801 0Z"/></svg></button><div class="Dropdown_dropdownMenu__Wu00a Dropdown_bannerActive__3cwTK"><div class="Dropdown_dropdownSectionSimple__sEwqQ"><ul class="Dropdown_dropdownList__nW6g9"><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/product-overview"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Product overview</span></a></li><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/how-it-works"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">How it works</span></a></li><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/integrations"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Integrations</span></a></li></ul></div></div></li><li class="Dropdown_dropdown__2i61_"><button class="Dropdown_dropdownButton__zXS7Q"><span class="Dropdown_buttonText__FpAtZ Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Solutions</span><svg viewbox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="Dropdown_dropdownButtonIcon__xEJFh"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.299 9.869a.567.567 0 0 1 0-.802l3.734-3.734 3.734 3.734a.567.567 0 0 1-.801.802L8.033 6.936 5.1 9.87a.567.567 0 0 1-.801 0Z"/></svg></button><div class="Dropdown_dropdownMenu__Wu00a Dropdown_dropdownFullWidth__ovVNw Dropdown_bannerActive__3cwTK"><div class="Dropdown_dropdownMenuFullWidthContent__XFWTt"><div class="Dropdown_dropdownSectionsWrapper__eYFqY"><div class=""><p class="Dropdown_dropdownHeader__qJZm1 Typography_styleBase__auQ0r Typography_styleS10__d6Ofw">Use cases</p><ul class="Dropdown_dropdownList__nW6g9 Navigation_navigationDropdownGridList__D9uC2"><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/infrastructure-governance"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/CICD.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/CICD-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Infrastructure Governance</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Standardize and control infrastructure provisioning and configuration</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/collaboration"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Team.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Team-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Collaboration</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Implement and automate secure, collaborative workflows</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/developer-velocity"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Speed.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Speed-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Developer Velocity</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Make it easy for developers to provision and configure with a single workflow</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/infrastructure-at-scale"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Productivity.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Productivity-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Infrastructure at Scale</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Scale your infrastructure safely and efficiently with an end-to-end workflow</span></span></a></li></ul></div><div class=""><p class="Dropdown_dropdownHeader__qJZm1 Typography_styleBase__auQ0r Typography_styleS10__d6Ofw">Industries</p><ul class="Dropdown_dropdownList__nW6g9"><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/industries/financial"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Financial</span></a></li><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/industries/technology"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Technology</span></a></li></ul></div></div><div class="Dropdown_dropdownWidget__8hvnU"><div class="PostWidget_post__nByRP"><span class="PostWidget_postImageWrapper__Es6zE"><img alt="" loading="lazy" width="1496" height="896" decoding="async" data-nimg="1" style="color:transparent;width:100%;height:auto" sizes="100vw" srcset="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=640&q=75 640w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=750&q=75 750w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=828&q=75 828w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=1080&q=75 1080w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=1200&q=75 1200w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=1920&q=75 1920w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=2048&q=75 2048w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=3840&q=75 3840w" src="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2024%2F06%2Febook-pic.png&w=3840&q=75"/></span><span tag="p" class="PostWidget_postLightContent__38iNm Typography_styleBase__auQ0r Typography_styleS8__WGhqY">Check out the Practitioner's Guide to Scaling IaC</span><a href="https://learn.spacelift.io/lp/practitioners-guide-to-scaling-iac" class="PostWidget_postLink__89x9s" external="true" nofollow="false">Read article</a></div></div></div></div></li><li class="Navigation_navigationLinkWrapper__b8uJD"><a class="mainMenuLink Navigation_navigationLink__VQkLC NavLink_link__bn4H6" href="https://docs.spacelift.io/"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Docs</span></a></li><li class="Navigation_navigationLinkWrapper__b8uJD"><a class="mainMenuLink Navigation_navigationLink__VQkLC NavLink_link__bn4H6" href="/pricing"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Pricing</span></a></li><li class="Dropdown_dropdown__2i61_"><button class="Dropdown_dropdownButton__zXS7Q"><span class="Dropdown_buttonText__FpAtZ Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Resources</span><svg viewbox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="Dropdown_dropdownButtonIcon__xEJFh"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.299 9.869a.567.567 0 0 1 0-.802l3.734-3.734 3.734 3.734a.567.567 0 0 1-.801.802L8.033 6.936 5.1 9.87a.567.567 0 0 1-.801 0Z"/></svg></button><div class="Dropdown_dropdownMenu__Wu00a Dropdown_dropdownFullWidth__ovVNw Dropdown_bannerActive__3cwTK"><div class="Dropdown_dropdownMenuFullWidthContent__XFWTt"><div class="Dropdown_dropdownSectionsWrapper__eYFqY Dropdown_dropdownSingleSectionWrapper__PxoC5"><div class=""><p class="Dropdown_dropdownHeader__qJZm1 Typography_styleBase__auQ0r Typography_styleS10__d6Ofw">Resources</p><ul class="Dropdown_dropdownList__nW6g9 Navigation_navigationDropdownGridList__D9uC2 Navigation_navigationDropdownGridListExpanded__Af5qt"><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/blog"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Blog.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Blog-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Blog</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Learn more about Spacelift and infrastructure best practices</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/partners"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Partners.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Partners-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Partners</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Our partners and their services</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/devops-conferences-events"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Events.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Events-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Events</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">See where we'll be next</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/cheat-sheets"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Cheatsheets.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Cheatsheets-2.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Ebooks & Cheatsheets</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Insights and quick guides to get you started</span></span></a></li><li class="Dropdown_dropdownItem__gAe1x Dropdown_dropdownItemTile__0uFFk"><a class="NavLink_link__bn4H6" href="/customers"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu"><div class="Dropdown_dropdownIconWrapper__D32M3"><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Users.svg"/><img alt="" loading="lazy" width="32" height="32" decoding="async" data-nimg="1" class="Dropdown_dropdownIcon__UIWq8 Dropdown_dropdownIconHover__XjYZP" style="color:transparent" src="https://spaceliftio.wpcomstaging.com/wp-content/uploads/2024/07/Users-1.svg"/></div><p class="Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Case studies</p><span class="Navigation_navigationTileDescription__PruIB Typography_styleBase__auQ0r Typography_styleCaption__3_pD9">Spacelift customer stories</span></span></a></li></ul></div></div><div class="Dropdown_dropdownWidget__8hvnU"><div class="PostWidget_post__nByRP"><span class="PostWidget_postImageWrapper__Es6zE"><img alt="What Makes Spacelift Secure" loading="lazy" width="834" height="508" decoding="async" data-nimg="1" style="color:transparent;width:100%;height:auto" sizes="100vw" srcset="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=640&q=75 640w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=750&q=75 750w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=828&q=75 828w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=1080&q=75 1080w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=1200&q=75 1200w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=1920&q=75 1920w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=2048&q=75 2048w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=3840&q=75 3840w" src="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F08%2F33.what-makes-spacelift-secure.png&w=3840&q=75"/></span><span tag="p" class="PostWidget_postLightContent__38iNm Typography_styleBase__auQ0r Typography_styleS8__WGhqY">What Makes Spacelift Secure</span><a href="/blog/what-makes-spacelift-secure" class="PostWidget_postLink__89x9s" external="true" nofollow="false">Read article</a></div></div></div></div></li><li class="Dropdown_dropdown__2i61_"><button class="Dropdown_dropdownButton__zXS7Q"><span class="Dropdown_buttonText__FpAtZ Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">About</span><svg viewbox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="Dropdown_dropdownButtonIcon__xEJFh"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.299 9.869a.567.567 0 0 1 0-.802l3.734-3.734 3.734 3.734a.567.567 0 0 1-.801.802L8.033 6.936 5.1 9.87a.567.567 0 0 1-.801 0Z"/></svg></button><div class="Dropdown_dropdownMenu__Wu00a Dropdown_bannerActive__3cwTK"><div class="Dropdown_dropdownSectionSimple__sEwqQ"><ul class="Dropdown_dropdownList__nW6g9"><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/about-us"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">About Us</span></a></li><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/partners"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Partners</span></a></li><li class="Dropdown_dropdownItem__gAe1x"><a class="mainMenuLink Navigation_navigationDropdownLink__wh1M_ NavLink_link__bn4H6" href="/contact"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Contact Us</span></a></li></ul></div></div></li><li class="Navigation_loginLink__r5RDd"><a class="mainMenuLink Navigation_navigationLink__VQkLC NavLink_link__bn4H6" href="/login"><span class="NavLink_linkText__LCKCK Typography_styleBase__auQ0r Typography_styleCaption2__WDDzu">Login</span></a></li></ul></div><ul class="Navigation_list__iaD8Z Navigation_fixedList__drCWq"><li class="Navigation_trialLink__Kd2bd"><a class="buttonLink ButtonLink_variantBase__vx6Jh ButtonLink_variantOutlined__8891m ButtonLink_sizeSM__9QZsW" href="/free-trial">Free trial</a></li><li class="Navigation_demoLink__YLvF9"><a class="buttonLink ButtonLink_variantBase__vx6Jh ButtonLink_variantContained__OAYUQ ButtonLink_sizeSM__9QZsW" href="/schedule-demo">Book a demo</a></li></ul></nav></div></header><div class="Navigation_overlay__x5Azp"/><div class="styles_main__PQ6DM styles_bannerActive__OGJhd"><div><div class="PostHeader_postHeader__c_5fW"><div class="PostHeader_wrapper__UdHJT"><div><a class="blogCategoryLink CategoryLabel_category__Y0E2z CategoryLabel_categoryDark__ooHli" href="/blog/docker">Docker</a><h1 class="PostHeader_title__Bn2q0 Typography_styleBase__auQ0r Typography_styleH5___kI04">Docker Volumes – Guide with Examples</h1><div class="PostHeader_postAuthor__VaGN3"><div class="PostHeader_postAuthorImgWrapper__FJz2Z"><span style="box-sizing:border-box;display:inline-block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative;max-width:100%"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;max-width:100%"><img style="display:block;max-width:100%;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0" alt="" aria-hidden="true" src="data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2740%27%20height=%2740%27/%3e"/></span><img alt="Docker Volumes &#8211; Guide with Examples" srcset="/_next/image?url=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F3f8e6bc091ca75d43f30317a656a2b24%3Fs%3D48%26d%3Dmm%26r%3Dg&w=48&q=75 1x, /_next/image?url=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F3f8e6bc091ca75d43f30317a656a2b24%3Fs%3D48%26d%3Dmm%26r%3Dg&w=96&q=75 2x" src="/_next/image?url=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F3f8e6bc091ca75d43f30317a656a2b24%3Fs%3D48%26d%3Dmm%26r%3Dg&w=96&q=75" decoding="async" data-nimg="intrinsic" class="PostHeader_postAuthorImg__Z4iP6" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/></span></div><div class="PostHeader_postAuthorWrapper__8epn7"><div class="PostHeader_postAuthorDetails__Tj10Q"><a class="blogPostLink" href="/blog/author/jamesw">James Walker</a><div class="PostHeader_postTime__MrHOM"><time class="PostHeader_postHeaderDate__uhThN"> <!-- -->23<!-- --> <!-- -->Mar<!-- --> <!-- -->2023</time>·<span class="PostHeader_postTimeReading__UiAMt">11 min read</span></div></div></div></div></div></div></div><div class="PostHeader_wrapper__UdHJT"><div class="PostHeader_postHeader__image__CrRom"><span style="box-sizing:border-box;display:block;overflow:hidden;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;position:relative"><span style="box-sizing:border-box;display:block;width:initial;height:initial;background:none;opacity:1;border:0;margin:0;padding:0;padding-top:60.91127098321343%"/><img alt="Guide to Docker Volumes" sizes="100vw" srcset="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=640&q=100 640w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=750&q=100 750w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=828&q=100 828w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=1080&q=100 1080w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=1200&q=100 1200w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=1920&q=100 1920w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=2048&q=100 2048w, /_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=3840&q=100 3840w" src="/_next/image?url=https%3A%2F%2Fspaceliftio.wpcomstaging.com%2Fwp-content%2Fuploads%2F2023%2F03%2F180.docker-volumes.png&w=3840&q=100" decoding="async" data-nimg="responsive" style="top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%"/></span></div></div></div><div class="PostRightBanner_wrapper__GeLTl PostRightBanner_visible__UyJLd"><div class="Container_root__MDMPu"><div class="PostShare_sticky__wBkGu PostShare_row__h8Ogm"><div class="Container_root__MDMPu"><div class="PostShare_shareWrapper__iG_zT PostShare_visible__9Cr1e"><ul class="PostShare_list__hMsVq"><li><a class="socialMediaLink SocialLink_iconLink__OaMMH SocialLink_iconLinkBig__GrsfG" rel="noreferrer" target="_blank" href="https://twitter.com/intent/tweet?text=Docker%20Volumes%20%E2%80%93%20Guide%20with%20Examples&tw_p=tweetbutton&url=https%3A%2F%2Fspacelift.io%2Fblog%2Fdocker-volumes"><svg viewbox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M24 4.3c-.9.4-1.8.7-2.8.8 1-.6 1.8-1.6 2.2-2.7-1 .6-2 1-3.1 1.2-.9-1-2.2-1.6-3.6-1.6-2.7 0-4.9 2.2-4.9 4.9 0 .4 0 .8.1 1.1-4.2-.2-7.8-2.2-10.2-5.2-.5.8-.7 1.6-.7 2.5 0 1.7.9 3.2 2.2 4.1-.8 0-1.6-.2-2.2-.6v.1c0 2.4 1.7 4.4 3.9 4.8-.4.1-.8.2-1.3.2-.3 0-.6 0-.9-.1.6 2 2.4 3.4 4.6 3.4-1.7 1.3-3.8 2.1-6.1 2.1-.4 0-.8 0-1.2-.1 2.2 1.4 4.8 2.2 7.5 2.2 9.1 0 14-7.5 14-14v-.6c1-.7 1.8-1.6 2.5-2.5Z"/></svg></a></li><li><a class="socialMediaLink SocialLink_iconLink__OaMMH SocialLink_iconLinkBig__GrsfG" rel="noreferrer" target="_blank" href="https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fspacelift.io%2Fblog%2Fdocker-volumes"><svg viewbox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M22.083 1H1.917C1.367 1 1 1.367 1 1.917v20.166c0 .55.367.917.917.917h20.166c.55 0 .917-.367.917-.917V1.917c0-.55-.367-.917-.917-.917ZM7.508 19.792H4.3V9.25h3.3v10.542h-.092ZM5.858 7.783c-1.008 0-1.925-.825-1.925-1.925 0-1.008.825-1.925 1.925-1.925 1.009 0 1.925.825 1.925 1.925s-.825 1.925-1.925 1.925Zm13.934 12.009h-3.3v-5.134c0-1.191 0-2.75-1.65-2.75-1.742 0-1.925 1.284-1.925 2.659v5.225h-3.3V9.25h3.116v1.467c.459-.825 1.467-1.65 3.117-1.65 3.3 0 3.942 2.2 3.942 5.041v5.684Z"/></svg></a></li><li><a class="socialMediaLink SocialLink_iconLink__OaMMH SocialLink_iconLinkBig__GrsfG" rel="noreferrer" target="_blank" href="https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fspacelift.io%2Fblog%2Fdocker-volumes&t=Docker%20Volumes%20%E2%80%93%20Guide%20with%20Examples"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M.007 0h23.986c.004 0 .007.003.007.007v23.986a.007.007 0 0 1-.007.007H.007A.007.007 0 0 1 0 23.993V.007C0 .003.003 0 .007 0Zm8.196 5.297H5.906l4.969 9.422V21h1.969v-6.281l5.25-9.469h-2.297L12 12.984 8.203 5.297Z" fill="currentColor"/></svg></a></li><li><a class="socialMediaLink SocialLink_iconLink__OaMMH SocialLink_iconLinkBig__GrsfG" rel="noreferrer" target="_blank" href="https://reddit.com/submit?url=https%3A%2F%2Fspacelift.io%2Fblog%2Fdocker-volumes&title=Docker%20Volumes%20%E2%80%93%20Guide%20with%20Examples"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M24 11.8c0-1.6-1.3-2.9-2.9-2.9-.7 0-1.3.2-1.8.6-1.8-1.1-4-1.8-6.4-1.9l1.2-3.9 3.4.8c.1 1.2 1.1 2.2 2.4 2.2 1.3 0 2.4-1.1 2.4-2.4 0-1.3-1.1-2.4-2.4-2.4-.9 0-1.7.5-2.1 1.3l-4-.9c-.3-.1-.7.1-.8.4l-1.5 4.9c-2.5.1-5 .7-6.8 1.9-.5-.4-1.1-.6-1.8-.6-1.6 0-2.9 1.3-2.9 2.9 0 1 .5 1.9 1.2 2.4v.7c0 2 1.2 3.8 3.3 5.2 2 1.3 4.7 2 7.5 2s5.5-.7 7.5-2c2.1-1.4 3.3-3.2 3.3-5.2v-.6c.7-.6 1.2-1.5 1.2-2.5Zm-4-8.6c.6 0 1.1.5 1.1 1.1 0 .6-.5 1.1-1.1 1.1-.6 0-1.1-.5-1.1-1.1 0-.6.5-1.1 1.1-1.1ZM6.8 13.6c0-.9.8-1.6 1.6-1.6.9 0 1.6.8 1.6 1.6s-.7 1.6-1.6 1.6c-.8 0-1.6-.7-1.6-1.6Zm9.2 4.7c-.8.8-2.1 1.2-3.9 1.2-1.8 0-3.1-.4-3.9-1.2-.3-.3-.3-.7 0-.9.3-.3.7-.3.9 0 .6.6 1.6.9 3 .9s2.4-.3 3-.9c.3-.3.7-.3.9 0 .2.3.2.7 0 .9Zm-.4-3.1c-.9 0-1.7-.7-1.7-1.6 0-.9.8-1.6 1.7-1.6.9 0 1.6.8 1.6 1.6s-.7 1.6-1.6 1.6Z" fill="currentColor"/></svg></a></li></ul></div></div></div><div class="PostRightBanner_container__v3jA0"><div class="PostRightBanner_cardWrapper__ouAA8"><h2 class="PostRightBanner_heading__w7Fsp Typography_styleBase__auQ0r Typography_styleH8__US2VD">Spacelift and Docker</h2><p class="PostRightBanner_text__E5RhY Typography_styleBase__auQ0r Typography_styleS9__CStzO">Customize your workflow by bringing your own Docker image and using it as a runner to accelerate deployments that leverage third-party tools.</p><a class="buttonLink ButtonLink_variantBase__vx6Jh ButtonLink_variantContained__OAYUQ ButtonLink_sizeSM__9QZsW" href="/schedule-demo">Book a demo</a></div></div></div></div><div class="Container_root__MDMPu"><div class="PostContent_postContent__EFXUR PostContent_rightBannerActive__wxyLE"><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><a href="https://spacelift.io/blog/docker-tutorial" target="_blank" rel="noopener">Docker containers</a> are easiest to use with stateless applications because their filesystems are ephemeral in nature. Changes made to a container’s environment are lost when the container stops, crashes, or gets replaced.</p> <p>You can Dockerize stateful applications such as databases and file servers by attaching <a href="https://docs.docker.com/storage/volumes" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">volumes</span></a> to your containers. Volumes provide persistent storage that’s independent of individual containers. You can reattach volumes to a different container after a failure or use them to share data between several containers simultaneously.</p> <p>In this article, you’ll learn what volumes are and the use cases they enable. We’ll also cover some practical examples of using volumes with Docker and Docker Compose.</p> </div></div><div class="PostContent_postHeader__9fzBw" id="what-are-docker-volumes"><h2>What Are Docker Volumes?<a class="PostContent_postHeaderLink__8Nfs1" href="#what-are-docker-volumes"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="PostContent_posteHeaderIcon__0bNht"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.799 9.999a.85.85 0 0 1 1.202 0c2.332 2.332 2.332 5.97 0 8.302l-2.8 2.8c-2.332 2.332-5.97 2.332-8.302 0s-2.332-5.97 0-8.302l.006-.006 2.506-2.406a.85.85 0 0 1 1.178 1.226l-2.494 2.394c-1.662 1.668-1.66 4.226.006 5.892 1.668 1.668 4.23 1.668 5.898 0l2.8-2.8c1.668-1.668 1.668-4.23 0-5.898a.85.85 0 0 1 0-1.202Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.899 4.101c-1.668-1.668-4.23-1.668-5.898 0l-2.8 2.8c-1.668 1.668-1.668 4.23 0 5.898a.85.85 0 1 1-1.202 1.202c-2.332-2.332-2.332-5.97 0-8.302l2.8-2.8c2.332-2.332 5.97-2.332 8.302 0s2.332 5.97 0 8.302l-.006.006-2.506 2.406a.85.85 0 1 1-1.178-1.226l2.494-2.394c1.662-1.668 1.66-4.226-.006-5.892Z" fill="currentColor"/></svg></a></h2></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><strong>Volumes</strong> are a mechanism for storing data outside containers. All volumes are managed by Docker and stored in a dedicated directory on your host, usually <code>/var/lib/docker/volumes</code> for Linux systems.</p> <p>Volumes are mounted to filesystem paths in your containers. When containers write to a path beneath a volume mount point, the changes will be applied to the volume instead of the container’s <a href="https://docs.docker.com/storage/storagedriver/#container-and-layers" target="_blank" rel="nofollow noopener">writable image layer</a>. The written data will still be available if the container stops – as the volume’s stored separately on your host, it can be remounted to another container or accessed directly using manual tools.</p> <p>Volumes work with both Linux and Windows containers. Several different <a href="https://docs.docker.com/storage/volumes/#use-a-volume-driver" target="_blank" rel="nofollow noopener">drivers</a> are available to store volume data in different services. Local storage on your Docker host is the default, but NFS volumes, CIFS/Samba shares, and device-level block storage adapters are available as alternatives. Third-party plugins can add extra storage options too.</p> <h3>Bind Mounts vs. Docker Volumes</h3> <p><a href="https://docs.docker.com/storage/bind-mounts" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">Bind mounts</span></a><span style="font-weight: 400;"> are another way to give containers access to files and folders on your host. They directly mount a host directory into your container. Any changes made to the directory will be reflected on both sides of the mount, whether the modification originates from the host or within the container.</span></p> <p><span style="font-weight: 400;">Bind mounts are best used for ad-hoc storage on a short-term basis. They’re convenient in development workflows. For example: bind mounting your working directory into a container automatically synchronizes your source code files, allowing you to immediately test changes without rebuilding your Docker image.</span></p> <p><span style="font-weight: 400;">Volumes are a better solution when you’re providing permanent storage to operational containers. Because they’re managed by Docker, you don’t need to manually maintain directories on your host. There’s less chance of data being accidentally modified and no dependency on a particular folder structure. Volume drivers also offer increased performance and the possibility of writing changes directly to remote locations.</span></p> <h3>When to Use Docker Volumes?</h3> <p><span style="font-weight: 400;">Volumes are designed to support the deployment of stateful Docker containers. You’ll need to use a volume when a container requires persistent storage to permanently save new and modified files.</span></p> <p><span style="font-weight: 400;">Typical volume use cases include the following:</span></p> <li style="font-weight: 400;" aria-level="1"><b>Database storage</b><span style="font-weight: 400;"> – You should mount a volume to the storage directories used by databases such as MySQL, Postgres, and Mongo. This will ensure your data persists after the container stops.</span></li> <li style="font-weight: 400;" aria-level="1"><b>Application data</b><span style="font-weight: 400;"> – Data generated by your application, such as file uploads, documents, and profile photos, should be stored in a volume.</span></li> <li style="font-weight: 400;" aria-level="1"><b>Essential caches</b><span style="font-weight: 400;"> – Consider using a volume to persist the contents of any caches, which would take significant time to rebuild.</span></li> <li style="font-weight: 400;" aria-level="1"><b>Convenient data backups</b><span style="font-weight: 400;"> – Docker’s centralized volume storage makes it easy to backup container data by mirroring </span><span style="font-weight: 400;">/var/lib/docker/volumes</span><span style="font-weight: 400;"> to another location. Community </span><a href="https://github.com/offen/docker-volume-backup" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">tools</span></a><span style="font-weight: 400;"> and </span><a href="https://www.docker.com/blog/back-up-and-share-docker-volumes-with-this-extension" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">Docker Desktop extensions</span></a><span style="font-weight: 400;"> can automate the process, providing a much simpler experience than manually copying individual bind-mounted directories.</span></li> <li style="font-weight: 400;" aria-level="1"><b>Share data between containers</b><span style="font-weight: 400;"> – Docker volumes can be mounted to multiple containers simultaneously. Containers have real-time access to the changes made by their neighbors.</span></li> <li style="font-weight: 400;" aria-level="1"><b>Write to remote filesystems</b><span style="font-weight: 400;"> – You’ll need to use a volume when you want containers to write to remote filesystems and </span><a href="https://docs.docker.com/storage/volumes/#create-a-service-which-creates-an-nfs-volume" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">network shares</span></a><span style="font-weight: 400;">. This can facilitate simpler workflows for applications that interact with your LAN resources.</span></li> <p><span style="font-weight: 400;">You don’t need to mount a volume to containers that don’t have writable filesystem paths or that only store disposable content. As a general rule, create a volume when your container’s writing data which will cause disruption if it’s lost.</span></p> </div></div><div class="PostContent_postHeader__9fzBw" id="example-using-docker-volumes"><h2>Example: Using Docker Volumes<a class="PostContent_postHeaderLink__8Nfs1" href="#example-using-docker-volumes"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="PostContent_posteHeaderIcon__0bNht"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.799 9.999a.85.85 0 0 1 1.202 0c2.332 2.332 2.332 5.97 0 8.302l-2.8 2.8c-2.332 2.332-5.97 2.332-8.302 0s-2.332-5.97 0-8.302l.006-.006 2.506-2.406a.85.85 0 0 1 1.178 1.226l-2.494 2.394c-1.662 1.668-1.66 4.226.006 5.892 1.668 1.668 4.23 1.668 5.898 0l2.8-2.8c1.668-1.668 1.668-4.23 0-5.898a.85.85 0 0 1 0-1.202Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.899 4.101c-1.668-1.668-4.23-1.668-5.898 0l-2.8 2.8c-1.668 1.668-1.668 4.23 0 5.898a.85.85 0 1 1-1.202 1.202c-2.332-2.332-2.332-5.97 0-8.302l2.8-2.8c2.332-2.332 5.97-2.332 8.302 0s2.332 5.97 0 8.302l-.006.006-2.506 2.406a.85.85 0 1 1-1.178-1.226l2.494-2.394c1.662-1.668 1.66-4.226-.006-5.892Z" fill="currentColor"/></svg></a></h2></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Let’s see how volumes work. You can start a container with a volume by setting the </span><span style="font-weight: 400;"><code>-v</code></span><span style="font-weight: 400;"> flag when you call </span><span style="font-weight: 400;"><code>docker run</code></span><span style="font-weight: 400;">.</span></p> <p><span style="font-weight: 400;">The following command starts a new Ubuntu 22.04 container and attaches your terminal to it (</span><span style="font-weight: 400;"><code>-it</code></span><span style="font-weight: 400;">), ready to run demonstration commands in the following steps. A volume called </span><span style="font-weight: 400;"><code>demo_volume</code></span><span style="font-weight: 400;"> is mounted to </span><span style="font-weight: 400;"><code>/data</code></span><span style="font-weight: 400;"> inside the container. Run the command now:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker run -it -v demo_volume:/data ubuntu:22.04</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">List the contents of your container’s </span><span style="font-weight: 400;"><code>/data</code></span><span style="font-weight: 400;"> directory:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ </span><span class="token" style="color:#DAD085">ls</span><span> /data</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The path exists, indicating the volume has mounted successfully, but no files have been created yet.</span></p> <p><span style="font-weight: 400;">Add a test file with some arbitrary content:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ </span><span class="token" style="color:#FFFFB6;text-decoration:underline">echo</span><span> </span><span class="token" style="color:#A8FF60">"foobar"</span><span> </span><span class="token" style="color:#EDEDED">></span><span> /data/foo <span>$ </span><span class="token" style="color:#DAD085">cat</span><span> /data/foo </span>foobar </code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Next, detach from your container by pressing Ctrl+C or running </span><span style="font-weight: 400;"><code>exit</code></span><span style="font-weight: 400;">:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ </span><span class="token" style="color:#FFFFB6;text-decoration:underline">exit</span><span> </span><span/><span class="token" style="color:#FFFFB6;text-decoration:underline">exit</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The container will immediately stop because there’s no other process running within it.</span></p> <p><span style="font-weight: 400;">Now, start a new container that attaches the same volume:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker run -it -v demo_volume:/app alpine:latest</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The </span><span style="font-weight: 400;"><code>demo_volume</code></span><span style="font-weight: 400;"> volume already exists so Docker will reuse it instead of creating a new one. This time, the volume is mounted to a different path inside the container, but when you list the path’s content, you’ll see the file that the first container created:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ </span><span class="token" style="color:#DAD085">cat</span><span> /app/foo </span>foobar </code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Docker persisted the volume’s content after the first container stopped, allowing it to be reused with your replacement container.</span></p> <h3>Manually Creating and Linking Volumes</h3> <p><span style="font-weight: 400;">This example above demonstrated how Docker automatically creates volumes when you reference a new name for the first time. You can manually create volumes ahead of time with the </span><span style="font-weight: 400;"><code>docker volume create</code></span><span style="font-weight: 400;"> command:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume create app_data </span>app_data </code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The volume can then be mounted to your containers in the same way as before:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker run -it -v app_data:/app alpine:latest</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><h3>Populating Volume Content</h3> <p><span style="font-weight: 400;">You can mount volumes to container paths that already contain data. When this happens, Docker will copy the existing container data into your new volume. This prevents accidental data loss. Other containers which use the volume will also see the content that’s been populated from neighboring mount points.</span></p> <h3>Mounting Volumes as Read-Only</h3> <p><span style="font-weight: 400;">Volumes are mounted in read-write mode by default. To mount a volume in read-only mode, include </span><span style="font-weight: 400;"><code>ro</code></span><span style="font-weight: 400;"> or </span><span style="font-weight: 400;"><code>readonly</code></span><span style="font-weight: 400;"> as the third field in your </span><span style="font-weight: 400;"><code>docker run</code></span><span style="font-weight: 400;"> command’s </span><span style="font-weight: 400;"><code>-v</code></span><span style="font-weight: 400;"> flag:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker run -it -v app_data:/app:ro alpine:latest</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The container will be able to read the volume’s content from the mount point but will be prevented from making modifications. This is ideal when a volume’s shared between multiple containers, only some of which are expected to perform writes. </span></p> <p><span style="font-weight: 400;">Write operations in containers with a readonly mount will fail with an error:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ echo </span><span class="token" style="color:#A8FF60">"foo"</span><span> </span><span class="token" style="color:#EDEDED">></span><span> </span><span class="token" style="color:#EDEDED">/</span><span>app</span><span class="token" style="color:#EDEDED">/</span><span>bar </span><span/><span class="token" style="color:#EDEDED">/</span><span>bin</span><span class="token" style="color:#EDEDED">/</span><span>sh</span><span class="token" style="color:#c5c8c6">:</span><span> can't create </span><span class="token" style="color:#EDEDED">/</span><span>app</span><span class="token" style="color:#EDEDED">/</span><span>bar</span><span class="token" style="color:#c5c8c6">:</span><span> Read</span><span class="token" style="color:#EDEDED">-</span><span>only file system</span></code></pre></div><div class="styles_wrapper__T7BXz"><div class="styles_cardWrapper__BogT0"><div class="styles_header__c38xk"><p class="Typography_styleBase__auQ0r Typography_styleH8__US2VD">💡 You might also like:</p></div><div class="styles_textWrapper__ObJU2"><div class="bodyTextWrapper WysiwigContent_wysiwigContent__LTO_a"><ul> <li><a href="https://spacelift.io/blog/devops-best-practices" target="_blank" rel="noopener"><span data-sheets-value="{"1":2,"2":"16 DevOps Best Practices to Follow"}" data-sheets-userformat="{"2":513,"3":{"1":0},"12":0}">16 DevOps Best Practices to Follow</span></a></li> <li><a href="https://spacelift.io/blog/ci-cd-tools" target="_blank" rel="noopener"><span data-sheets-value="{"1":2,"2":"Top Most Useful CI/CD Tools for DevOps"}" data-sheets-userformat="{"2":513,"3":{"1":0},"12":0}">Top Most Useful CI/CD Tools for DevOps</span></a></li> <li><a href="https://spacelift.io/blog/docker-commands-cheat-sheet" target="_blank" rel="noopener"><span data-sheets-root="1">Docker Cheat Sheet – 36 Docker CLI Commands</span></a></li> </div></div></div></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><h3>Reusing Volumes When Containers Start</h3> <p><span style="font-weight: 400;">Sometimes you might want to start a new container with the same volumes as an existing container on your host. Instead of repeating the list of </span><span style="font-weight: 400;"><code>-v</code></span><span style="font-weight: 400;"> flags required, you can use </span><span style="font-weight: 400;"><code>--volumes-from</code></span><span style="font-weight: 400;"> to automatically include another container’s volumes:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span># Create the first container </span><span>$ docker run </span><span class="token" style="color:#EDEDED">-</span><span>d </span><span class="token" style="color:#EDEDED">--</span><span>name db </span><span class="token" style="color:#EDEDED">-</span><span>v app_data</span><span class="token" style="color:#c5c8c6">:</span><span class="token" style="color:#EDEDED">/</span><span>data database</span><span class="token" style="color:#EDEDED">-</span><span>image</span><span class="token" style="color:#c5c8c6">:</span><span>latest <!-- --># Create the second container <span>$ docker run </span><span class="token" style="color:#EDEDED">-</span><span>d </span><span class="token" style="color:#EDEDED">--</span><span>name backup </span><span class="token" style="color:#EDEDED">--</span><span>volumes</span><span class="token" style="color:#EDEDED">-</span><span>from db backup</span><span class="token" style="color:#EDEDED">-</span><span>image</span><span class="token" style="color:#c5c8c6">:</span><span>latest</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Docker will mount all the volumes that are already attached to the existing container. The same destination paths will be used to mount the volumes into your new container.</span></p> <p><span style="font-weight: 400;">This feature is useful when you’re backing up an existing container’s volumes. You can easily mount a target container’s volumes into a new container running a dedicated backup image.</span></p> </div></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><h3>Using Volumes in Dockerfiles</h3> <p><span style="font-weight: 400;">Docker allows images to define volume mount points with the </span><a href="https://docs.docker.com/engine/reference/builder/#volume" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;"><code>VOLUME</code></span><span style="font-weight: 400;"> Dockerfile instruction</span></a><span style="font-weight: 400;">. When a container is started from an image, Docker will automatically create new volumes for the mount points listed in the <a href="https://spacelift.io/blog/dockerfile" target="_blank" rel="noopener">Dockerfile</a>.</span></p> <p><span style="font-weight: 400;">The following Dockerfile will </span><i><span style="font-weight: 400;">always</span></i><span style="font-weight: 400;"> mount a volume to </span><span style="font-weight: 400;"><code>/app_data</code></span><span style="font-weight: 400;"> inside the container, even if you call </span><span style="font-weight: 400;"><code>docker run</code></span><span style="font-weight: 400;"> without the </span><span style="font-weight: 400;"><code>-v</code></span><span style="font-weight: 400;"> flag:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>FROM ubuntu</span><span class="token" style="color:#c5c8c6">:</span><span class="token" style="color:#FF73FD">22.04</span><span> </span><span>VOLUME </span><span class="token" style="color:#EDEDED">/</span><span>app_data</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">You can still manually mount a new or existing volume to paths referenced by </span><span style="font-weight: 400;"><code>VOLUME</code></span><span style="font-weight: 400;"> instructions. The </span><span style="font-weight: 400;"><code>-v</code></span><span style="font-weight: 400;"> flag overrides the Dockerfile’s content:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker run </span><span class="token" style="color:#EDEDED">-</span><span>v custom_volume</span><span class="token" style="color:#c5c8c6">:</span><span class="token" style="color:#EDEDED">/</span><span>app_data app</span><span class="token" style="color:#EDEDED">-</span><span>image</span><span class="token" style="color:#c5c8c6">:</span><span>latest</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The </span><span style="font-weight: 400;"><code>VOLUME</code></span><span style="font-weight: 400;"> instruction ensures that critical paths are always persisted when users start a new container. However, it should be treated carefully because users won’t necessarily expect this behavior. Using </span><span style="font-weight: 400;"><code>VOLUME</code></span><span style="font-weight: 400;"> removes the choice of creating a purely ephemeral container for debugging or testing purposes.</span></p> </div></div><div class="PostContent_postHeader__9fzBw" id="interacting-with-docker-volumes"><h2>Interacting With Docker Volumes<a class="PostContent_postHeaderLink__8Nfs1" href="#interacting-with-docker-volumes"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="PostContent_posteHeaderIcon__0bNht"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.799 9.999a.85.85 0 0 1 1.202 0c2.332 2.332 2.332 5.97 0 8.302l-2.8 2.8c-2.332 2.332-5.97 2.332-8.302 0s-2.332-5.97 0-8.302l.006-.006 2.506-2.406a.85.85 0 0 1 1.178 1.226l-2.494 2.394c-1.662 1.668-1.66 4.226.006 5.892 1.668 1.668 4.23 1.668 5.898 0l2.8-2.8c1.668-1.668 1.668-4.23 0-5.898a.85.85 0 0 1 0-1.202Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.899 4.101c-1.668-1.668-4.23-1.668-5.898 0l-2.8 2.8c-1.668 1.668-1.668 4.23 0 5.898a.85.85 0 1 1-1.202 1.202c-2.332-2.332-2.332-5.97 0-8.302l2.8-2.8c2.332-2.332 5.97-2.332 8.302 0s2.332 5.97 0 8.302l-.006.006-2.506 2.406a.85.85 0 1 1-1.178-1.226l2.494-2.394c1.662-1.668 1.66-4.226-.006-5.892Z" fill="currentColor"/></svg></a></h2></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">The Docker CLI includes a set of commands for interacting with the volumes on your host.</span></p> <p><span style="font-weight: 400;">List all your volumes with </span><span style="font-weight: 400;"><code>docker volume ls</code></span><span style="font-weight: 400;">:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume </span><span class="token" style="color:#DAD085">ls</span><span> </span>DRIVER VOLUME NAME <span/><span class="token" style="color:#FFFFB6;text-decoration:underline">local</span><span> app_data </span><span/><span class="token" style="color:#FFFFB6;text-decoration:underline">local</span><span> demo_volume</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">You’ll see the name of each volume and the storage driver it’s backed by. To access more detailed information about a specific volume, use </span><span style="font-weight: 400;"><code>docker volume inspect</code></span><span style="font-weight: 400;"> instead:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume inspect demo_volume </span><span> </span><span class="token" style="color:#A8FF60">"CreatedAt"</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#A8FF60">"2023-03-16T14:05:55Z"</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Driver"</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#A8FF60">"local"</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Labels"</span><span class="token" style="color:#c5c8c6">:</span><span> null</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Mountpoint"</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#A8FF60">"/var/lib/docker/volumes/demo_volume/_data"</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Name"</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#A8FF60">"demo_volume"</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Options"</span><span class="token" style="color:#c5c8c6">:</span><span> null</span><span class="token" style="color:#c5c8c6">,</span><span> </span><span> </span><span class="token" style="color:#A8FF60">"Scope"</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#A8FF60">"local"</span><span> </span><span/><span class="token" style="color:#c5c8c6">]</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Delete a volume with </span><span style="font-weight: 400;"><code>docker volume rm</code></span><span style="font-weight: 400;">:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume rm demo_volume </span>demo_volume </code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Volumes which are currently mounted to a container can’t be deleted unless you add the </span><span style="font-weight: 400;"><code>-f</code></span><span style="font-weight: 400;"> (force) flag:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-bash" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume </span><span class="token" style="color:#DAD085">rm</span><span> app_data -f</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Finally, you can clean up all unused volumes with </span><span style="font-weight: 400;"><code>docker volume prune</code></span><span style="font-weight: 400;">. The command deletes volumes that aren’t mounted to at least one container. You’ll be shown a confirmation prompt before the prune begins. After it completes, the total amount of freed disk space will be displayed in your terminal.</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-go" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span>$ docker volume prune </span><span>WARNING</span><span class="token" style="color:#EDEDED">!</span><span> This will remove all local volumes not used by at least one container</span><span class="token" style="color:#c5c8c6">.</span><span> </span><span>Total reclaimed space</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#FF73FD">6</span><span>B</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p>Check out other Docker CLI commands in our <a href="https://spacelift.io/blog/docker-commands-cheat-sheet" target="_blank" rel="noopener">Docker cheat sheet</a>.</p> </div></div><div class="PostContent_postHeader__9fzBw" id="using-volumes-with-docker-compose"><h2>Using Volumes With Docker Compose<a class="PostContent_postHeaderLink__8Nfs1" href="#using-volumes-with-docker-compose"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="PostContent_posteHeaderIcon__0bNht"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.799 9.999a.85.85 0 0 1 1.202 0c2.332 2.332 2.332 5.97 0 8.302l-2.8 2.8c-2.332 2.332-5.97 2.332-8.302 0s-2.332-5.97 0-8.302l.006-.006 2.506-2.406a.85.85 0 0 1 1.178 1.226l-2.494 2.394c-1.662 1.668-1.66 4.226.006 5.892 1.668 1.668 4.23 1.668 5.898 0l2.8-2.8c1.668-1.668 1.668-4.23 0-5.898a.85.85 0 0 1 0-1.202Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.899 4.101c-1.668-1.668-4.23-1.668-5.898 0l-2.8 2.8c-1.668 1.668-1.668 4.23 0 5.898a.85.85 0 1 1-1.202 1.202c-2.332-2.332-2.332-5.97 0-8.302l2.8-2.8c2.332-2.332 5.97-2.332 8.302 0s2.332 5.97 0 8.302l-.006.006-2.506 2.406a.85.85 0 1 1-1.178-1.226l2.494-2.394c1.662-1.668 1.66-4.226-.006-5.892Z" fill="currentColor"/></svg></a></h2></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Volumes can also be defined and used in </span><a href="https://spacelift.io/blog/docker-compose" target="_blank" rel="noopener"><span style="font-weight: 400;">Docker Compose</span></a><span style="font-weight: 400;">. In your </span><span style="font-weight: 400;"><code>docker-compose.yml</code></span><span style="font-weight: 400;"> file, add a top-level </span><span style="font-weight: 400;"><code>volumes</code></span><span style="font-weight: 400;"> field that lists the volumes to create, then mount your volumes into your containers within the </span><span style="font-weight: 400;"><code>services</code></span><span style="font-weight: 400;"> section:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-yaml" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span class="token key" style="color:#F9EE98">services</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> </span><span class="token key" style="color:#F9EE98">app</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> </span><span class="token key" style="color:#F9EE98">image</span><span class="token" style="color:#c5c8c6">:</span><span> app</span><span class="token" style="color:#c5c8c6">-</span><span>image</span><span class="token" style="color:#c5c8c6">:</span><span>latest </span><span> </span><span class="token key" style="color:#F9EE98">volumes</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> </span><span class="token" style="color:#c5c8c6">-</span><span> app_data</span><span class="token" style="color:#c5c8c6">:</span><span>/data </span><span/><span class="token key" style="color:#F9EE98">volumes</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> app_data</span><span class="token" style="color:#c5c8c6">:</span></code></pre></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Compose automatically creates and mounts your volumes when you run </span><span style="font-weight: 400;"><code>docker compose up</code></span><span style="font-weight: 400;">. To use an existing volume, add it to the </span><span style="font-weight: 400;"><code>volumes</code></span><span style="font-weight: 400;"> section of your </span><span style="font-weight: 400;">docker-compose.yml</span><span style="font-weight: 400;"> file and set the </span><span style="font-weight: 400;"><code>external</code></span><span style="font-weight: 400;"> flag to </span><span style="font-weight: 400;"><code>true</code></span><span style="font-weight: 400;">:</span></p> </div></div><div class="PostContent_postText__WYliF"><pre style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;border-radius:0.3em;background:#1d1f21"><code class="language-yaml" style="color:#c5c8c6;text-shadow:0 1px rgba(0, 0, 0, 0.3);font-family:Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span class="token key" style="color:#F9EE98">volumes</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> </span><span class="token key" style="color:#F9EE98">demo_volume</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span> </span><span class="token key" style="color:#F9EE98">external</span><span class="token" style="color:#c5c8c6">:</span><span> </span><span class="token" style="color:#fd971f;font-weight:bold">true</span></code></pre></div><div class="PostContent_postHeader__9fzBw" id="key-points"><h2>Key Points<a class="PostContent_postHeaderLink__8Nfs1" href="#key-points"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="PostContent_posteHeaderIcon__0bNht"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.799 9.999a.85.85 0 0 1 1.202 0c2.332 2.332 2.332 5.97 0 8.302l-2.8 2.8c-2.332 2.332-5.97 2.332-8.302 0s-2.332-5.97 0-8.302l.006-.006 2.506-2.406a.85.85 0 0 1 1.178 1.226l-2.494 2.394c-1.662 1.668-1.66 4.226.006 5.892 1.668 1.668 4.23 1.668 5.898 0l2.8-2.8c1.668-1.668 1.668-4.23 0-5.898a.85.85 0 0 1 0-1.202Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.899 4.101c-1.668-1.668-4.23-1.668-5.898 0l-2.8 2.8c-1.668 1.668-1.668 4.23 0 5.898a.85.85 0 1 1-1.202 1.202c-2.332-2.332-2.332-5.97 0-8.302l2.8-2.8c2.332-2.332 5.97-2.332 8.302 0s2.332 5.97 0 8.302l-.006.006-2.506 2.406a.85.85 0 1 1-1.178-1.226l2.494-2.394c1.662-1.668 1.66-4.226-.006-5.892Z" fill="currentColor"/></svg></a></h2></div><div class="PostContent_postText__WYliF"><div class="PostWysiwyg_wysiwygContent__EylVy"><p><span style="font-weight: 400;">Docker </span><a href="https://docs.docker.com/storage/volumes" target="_blank" rel="nofollow noopener"><span style="font-weight: 400;">volumes</span></a><span style="font-weight: 400;"> provide persistent storage for your containers. Docker manages the data in your volumes separately to your containers. Volumes can be attached to multiple containers simultaneously, remain accessible after the containers they’re mounted to are stopped, and can be centrally managed using the Docker CLI.</span></p> <p><span style="font-weight: 400;">Mount a volume whenever your containerized applications need to permanently store filesystem changes. Data stored in volumes is protected against container failures and restarts, but changes to any other paths in the container will be lost.</span></p> <p><span style="font-weight: 400;">Looking for more information about Docker and its features? Check out our </span><a href="https://spacelift.io/blog/docker-tutorial" target="_blank" rel="noopener"><span style="font-weight: 400;">beginner’s tutorial</span></a><span style="font-weight: 400;">, or browse the other articles on the </span><a href="https://spacelift.io/blog" target="_blank" rel="noopener"><span style="font-weight: 400;">Spacelift blog</span></a><span style="font-weight: 400;">.</span></p> <p>Packaging software as a container makes it more portable, allowing you to eliminate discrepancies between environments. You can use the container on your laptop, in production, and within your CI/CD infrastructure. Take a look at how <a href="https://spacelift.io/" target="_blank" rel="noopener">Spacelift</a> uses Docker containers to run CI jobs. You have the possibility of bringing your own Docker image and <a href="https://docs.spacelift.io/integrations/docker" target="_blank" rel="noopener">using it as a runner</a> to speed up the deployments that leverage third party tools. Spacelift’s official runner image can be found <a href="https://github.com/spacelift-io/runner-terraform" target="_blank" rel="nofollow noopener">here</a>.</p>
推荐文章
大鼻子的灌汤包
·
百度网盘 Mac 版 - Mac知道
4 月前
爱跑步的豆芽
·
ckeditor编辑的使用方法 - Y档案Y - 博客园
4 月前
鬼畜的钢笔
·
Cmake 编译静库 动态库 指定输出路径_cmake指定动态库输出目录-CSDN博客
5 月前
玩足球的乒乓球
·
第四屆「我是自己的健康小主人」穗港澳中小學健康促進交流活動 - 香港教育工作者聯會
6 月前
买醉的鸡蛋
·
为什么 Android 们的相机不愿用大底了?| 硬哲学 | 爱范儿
6 月前