CINXE.COM
Dockerfile reference | Docker Docs
<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Dockerfile reference | Docker Docs </title><meta name=description content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta name=keywords content="dockerfile,docker file,docker copy,dockerfile exec,docker entrypoint,dockerfile entrypoint,dockerfile arg,docker args,entrypoint,shell dockerfile"><link rel=canonical href=https://docs.docker.com/reference/dockerfile/><link rel=icon type=image/x-icon href=https://docs.docker.com/favicons/docs@2x.ico sizes=129x128><link rel=apple-touch-icon type=image/x-icon href=https://docs.docker.com/favicons/docs@2x.ico sizes=129x128><meta name=msapplication-TileImage content="https://docs.docker.com/favicons/docs@2x.ico"><meta name=theme-color content="#2496ed"><meta name=twitter:title itemprop="title name" content="Dockerfile reference"><meta name=twitter:description property="og:description" itemprop=description content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta name=twitter:card content="summary_large_image"><meta name=twitter:domain content="https://docs.docker.com/"><meta name=twitter:site content="@docker_docs"><meta name=twitter:url content="https://twitter.com/docker_docs"><meta name=twitter:image:src content="https://docs.docker.com/images/thumbnail.webp"><meta name=twitter:image:alt content="Docker Documentation"><meta property="og:title" content="Dockerfile reference"><meta property="og:description" content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta property="og:type" content="website"><meta property="og:updated_time" itemprop=dateUpdated content="2025-01-21 13:54:16 +0100 +0100"><meta property="og:image" itemprop="image primaryImageOfPage" content="https://docs.docker.com/images/thumbnail.webp"><meta property="og:locale" content="en_US"><meta property="og:url" content="https://docs.docker.com/reference/dockerfile/"><meta property="og:site_name" content="Docker Documentation"><meta property="article:published_time" itemprop=datePublished content="2025-01-21 13:54:16 +0100 +0100"><script type=application/ld+json>{"@context":"https://schema.org","@type":"WebPage","headline":"\"Dockerfile reference\"","description":"\"Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more.\"","url":"https:\/\/docs.docker.com\/reference\/dockerfile\/"}</script><script src=https://cdn.cookielaw.org/scripttemplates/otSDKStub.js type=text/javascript data-domain-script=65425fb0-7b36-4317-9f10-7b3e08039af0></script><script type=text/javascript>function OptanonWrapper(){}</script><script>(function(e,t,n,s,o){e[s]=e[s]||[],e[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var a=t.getElementsByTagName(n)[0],i=t.createElement(n),r=s!="dataLayer"?"&l="+s:"";i.async=!0,i.src="https://www.googletagmanager.com/gtm.js?id="+o+r,a.parentNode.insertBefore(i,a)})(window,document,"script","dataLayer","GTM-WL2QLG5")</script><script>(function(e,t,n,s,o,i){e.hj=e.hj||function(){(e.hj.q=e.hj.q||[]).push(arguments)},e._hjSettings={hjid:3169877,hjsv:6},o=t.getElementsByTagName("head")[0],i=t.createElement("script"),i.async=1,i.src=n+e._hjSettings.hjid+s+e._hjSettings.hjsv,o.appendChild(i)})(window,document,"https://static.hotjar.com/c/hotjar-",".js?sv=")</script><script async src=https://widget.kapa.ai/kapa-widget.bundle.js data-button-hide=true data-font-family="Roboto Flex,sans-serif" data-modal-disclaimer-bg-color=#e5f2fc data-modal-disclaimer-text-color=#086dd7 data-modal-disclaimer="This is a custom LLM for answering questions about Docker. Answers are based on the contents of the documentation. Rate the answers to let us know what you think!" data-kapa-branding-text="powered by [kapa.ai](https://www.kapa.ai) and Docker" data-modal-header-bg-color=#1d63ed data-modal-image-height=25px data-modal-image-width=181px data-modal-title= data-modal-override-open-class=open-kapa-widget data-modal-ask-ai-input-placeholder="Ask me a question about Docker…" data-modal-title-color=#fff data-project-color=#1d63ed data-project-logo=/assets/images/logo-icon-white.svg data-project-name=Docker data-user-analytics-fingerprint-enabled=true data-website-id=ba5c2cbc-6535-4334-a72e-050f7a681c8a></script><link href=/assets/fonts/RobotoFlex.woff2 rel=preload as=font type=font/woff2 crossorigin><style>body>img{display:none}</style><link href="https://docs.docker.com/css/styles.min.6cf4825d17631ae59d150b53dcd71fd448a7c5cb17b83ed4853902a925893a60.css" rel=stylesheet><script>(()=>{function t(){let e=localStorage.getItem("theme-preference");return e||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}var e=t();document.firstElementChild.className=e==="dark"?"dark":"light",localStorage.setItem("theme-preference",e)})()</script><script defer src=https://docs.docker.com/scripts.js></script></head><body class="flex flex-col items-center bg-gradient-to-r from-background-light from-20% to-white to-30% text-base dark:from-gray-dark-100 dark:to-background-dark dark:text-white"><header class="w-full sticky top-0 z-20 h-16 px-6 text-white bg-gradient-to-r from-blue-light-600 to-blue-light dark:from-blue-dark-200 to-50% dark:to-blue-dark-100"><div class="max-w-[1920px] mx-auto flex lg:gap-8 gap-2 h-full items-center justify-between"><div class="flex h-full items-center lg:gap-8 gap-2"><button x-data @click="$store.showSidebar = true" class="icon-svg block px-4 md:hidden h-full" aria-label=Menu><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M150-240q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150zm0-210q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150zm0-210q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150z"/></svg></button><div><a title="Docker Docs home page" href=https://docs.docker.com/><div class="hidden sm:block"><svg width="160" height="24" viewBox="0 0 160 24" fill="none"><path d="M23.6087 10.3866C23.0202 9.98965 21.4744 9.81999 20.3501 10.1235 20.2896 9.00129 19.7119 8.05574 18.656 7.23081L18.2647 6.96776 18.0038 7.36233C17.4914 8.14134 17.2763 9.17951 17.3524 10.1235 17.413 10.7048 17.6148 11.3586 18.0038 11.8333c-1.4627.8506-2.8113.6576-8.78345.6576H.00209363C-.0250805 13.8427.192313 16.4428 1.8414 18.5588 2.02385 18.7923 2.22339 19.0187 2.44001 19.2366c1.34085 1.3464 3.36726 2.3332 6.39757 2.3363C13.4603 21.5768 17.4207 19.0724 19.8299 13.017 20.6226 13.0302 22.715 13.1594 23.7391 11.1757 23.764 11.1422 24 10.6496 24 10.6496L23.6087 10.3866zM6.01846 8.99195H3.42604V11.5905H6.01846V8.99195zm3.34941.0H6.77545V11.5905H9.36787V8.99195zm3.34943.0H10.1249V11.5905h2.5924V8.99195zm3.3494.0H13.4743V11.5905h2.5924V8.99195zm-13.39843.0H.0766285V11.5905H2.66905L2.66827 8.99195zM6.01768 5.70936H3.42526V8.30788H6.01768V5.70936zm3.34941.0H6.77468V8.30788H9.36709V5.70936zm3.34941.0H10.1241V8.30788h2.5924V5.70936zm0-3.2826H10.1241V5.02529h2.5924V2.42676z" fill="#fff"/><path d="M35.774 21.092C34.578 21.092 33.497 20.816 32.531 20.264 31.5803 19.6967 30.8213 18.93 30.254 17.964 29.702 16.998 29.426 15.9093 29.426 14.698s.253-2.2923.759-3.243C30.7063 10.489 31.4117 9.73 32.301 9.178 33.1903 8.61067 34.1947 8.327 35.314 8.327 36.2187 8.327 37.0543 8.51867 37.821 8.902 38.5877 9.27 39.2317 9.776 39.753 10.42V4.21C39.753 3.85733 39.8603 3.57367 40.075 3.359 40.305 3.14433 40.5887 3.037 40.926 3.037 41.2787 3.037 41.5623 3.14433 41.777 3.359S42.099 3.85733 42.099 4.21V14.698C42.099 15.9093 41.8153 16.998 41.248 17.964 40.696 18.93 39.9447 19.6967 38.994 20.264 38.0433 20.816 36.97 21.092 35.774 21.092zm0-2.07C36.556 19.022 37.2537 18.838 37.867 18.47 38.4803 18.0867 38.9633 17.5653 39.316 16.906 39.6687 16.2467 39.845 15.5107 39.845 14.698 39.845 13.87 39.6687 13.134 39.316 12.49 38.9633 11.846 38.4803 11.34 37.867 10.972 37.2537 10.5887 36.556 10.397 35.774 10.397 35.0073 10.397 34.3097 10.5887 33.681 10.972 33.0677 11.34 32.577 11.846 32.209 12.49 31.8563 13.134 31.68 13.87 31.68 14.698 31.68 15.5107 31.8563 16.2467 32.209 16.906 32.577 17.5653 33.0677 18.0867 33.681 18.47 34.3097 18.838 35.0073 19.022 35.774 19.022zm15.1719 2.07c-1.242.0-2.3384-.2683-3.289-.805C46.7062 19.735 45.9549 18.9837 45.4029 18.033 44.8662 17.067 44.5979 15.963 44.5979 14.721c0-1.2573.268299999999996-2.3613.805-3.312C45.9549 10.443 46.7062 9.69167 47.6569 9.155 48.6075 8.603 49.7039 8.327 50.9459 8.327 52.1725 8.327 53.2612 8.603 54.2119 9.155 55.1625 9.69167 55.9062 10.443 56.4429 11.409 56.9949 12.3597 57.2709 13.4637 57.2709 14.721c0 1.242-.2684 2.346-.805 3.312C55.9292 18.9837 55.1855 19.735 54.2349 20.287c-.950700000000005.5367-2.047.805-3.289.805zm0-2.07c.7973.0 1.5026-.183999999999998 2.116-.552C53.6752 18.102 54.1505 17.596 54.4879 16.952 54.8405 16.308 55.0169 15.5643 55.0169 14.721S54.8405 13.134 54.4879 12.49C54.1505 11.8307 53.6752 11.317 53.0619 10.949 52.4485 10.581 51.7432 10.397 50.9459 10.397 50.1485 10.397 49.4432 10.581 48.8299 10.949 48.2165 11.317 47.7335 11.8307 47.3809 12.49 47.0282 13.134 46.8519 13.8777 46.8519 14.721S47.0282 16.308 47.3809 16.952C47.7335 17.596 48.2165 18.102 48.8299 18.47 49.4432 18.838 50.1485 19.022 50.9459 19.022zm14.5205 2.07C64.2397 21.092 63.1434 20.816 62.1774 20.264 61.2267 19.6967 60.4754 18.9377 59.9234 17.987 59.3867 17.021 59.1184 15.9323 59.1184 14.721c0-1.242.268299999999996-2.346.805-3.312C60.46 10.443 61.196 9.69167 62.1314 9.155 63.0667 8.603 64.14 8.327 65.3514 8.327 66.256 8.327 67.084 8.50333 67.8354 8.856 68.5867 9.19333 69.2614 9.707 69.8594 10.397 70.0741 10.6423 70.1507 10.8953 70.0894 11.156S69.8594 11.6467 69.5834 11.846C69.3687 11.9993 69.1311 12.053 68.8704 12.007 68.6097 11.9457 68.372 11.8077 68.1574 11.593 67.406 10.7957 66.4707 10.397 65.3514 10.397 64.5694 10.397 63.8794 10.581 63.2814 10.949 62.6834 11.3017 62.2157 11.8 61.8784 12.444 61.541 13.088 61.3724 13.847 61.3724 14.721 61.3724 15.549 61.541 16.285 61.8784 16.929 62.231 17.573 62.714 18.0867 63.3274 18.47 63.9407 18.838 64.6537 19.022 65.4664 19.022 66.0031 19.022 66.4707 18.9607 66.8694 18.838 67.2834 18.7 67.6591 18.493 67.9964 18.217 68.2417 18.0177 68.4947 17.9103 68.7554 17.895 69.0161 17.8643 69.2461 17.9333 69.4454 18.102 69.706 18.3167 69.8517 18.562 69.8824 18.838 69.913 19.0987 69.821 19.3363 69.6064 19.551 68.5024 20.5783 67.1224 21.092 65.4664 21.092zM74.7839 16.4l-1.426-1.564L80.4189 8.534C80.6489 8.31933 80.9019 8.21967 81.1779 8.235 81.4692 8.25033 81.7145 8.373 81.9139 8.603 82.1285 8.833 82.2282 9.086 82.2129 9.362 82.1975 9.638 82.0749 9.88333 81.8449 10.098L74.7839 16.4zM73.7029 21C73.3655 21 73.0895 20.9003 72.8749 20.701 72.6755 20.4863 72.5759 20.2103 72.5759 19.873V4.164C72.5759 3.82667 72.6755 3.55833 72.8749 3.359 73.0895 3.14433 73.3655 3.037 73.7029 3.037 74.0402 3.037 74.3085 3.14433 74.5079 3.359 74.7225 3.55833 74.8299 3.82667 74.8299 4.164V19.873C74.8299 20.2103 74.7225 20.4863 74.5079 20.701 74.3085 20.9003 74.0402 21 73.7029 21zM81.9139 20.885C81.6685 21.0843 81.3925 21.1687 81.0859 21.138 80.7945 21.1227 80.5492 20.9923 80.3499 20.747L75.6809 14.974l1.61-1.518L82.0749 19.344C82.2742 19.5893 82.3585 19.8577 82.3279 20.149 82.3125 20.425 82.1745 20.6703 81.9139 20.885zM89.4361 21.092c-1.2727.0-2.4074-.2683-3.404-.805C85.0507 19.735 84.2764 18.9837 83.7091 18.033 83.1571 17.067 82.8811 15.963 82.8811 14.721 82.8811 13.4637 83.1417 12.3597 83.6631 11.409 84.1997 10.443 84.9357 9.69167 85.8711 9.155 86.8064 8.603 87.8797 8.327 89.0911 8.327 90.2871 8.327 91.3144 8.59533 92.1731 9.132 93.0317 9.65333 93.6834 10.3817 94.1281 11.317 94.5881 12.237 94.8181 13.3027 94.8181 14.514 94.8181 14.8053 94.7184 15.0507 94.5191 15.25 94.3197 15.434 94.0667 15.526 93.7601 15.526H84.4911v-1.84h9.2L92.7481 14.33C92.7327 13.5633 92.5794 12.881 92.2881 12.283 91.9967 11.6697 91.5827 11.1867 91.0461 10.834 90.5094 10.4813 89.8577 10.305 89.0911 10.305 88.2171 10.305 87.4657 10.4967 86.8371 10.88 86.2237 11.2633 85.7561 11.7923 85.4341 12.467 85.1121 13.1263 84.9511 13.8777 84.9511 14.721S85.1427 16.3157 85.5261 16.975C85.9094 17.6343 86.4384 18.1557 87.1131 18.539 87.7877 18.9223 88.5621 19.114 89.4361 19.114 89.9114 19.114 90.3944 19.0297 90.8851 18.861 91.3911 18.677 91.7974 18.47 92.1041 18.24 92.3341 18.0713 92.5794 17.987 92.8401 17.987 93.1161 17.9717 93.3537 18.0483 93.5531 18.217 93.8137 18.447 93.9517 18.7 93.9671 18.976 93.9824 19.252 93.8597 19.4897 93.5991 19.689 93.0777 20.103 92.4261 20.4403 91.6441 20.701 90.8774 20.9617 90.1414 21.092 89.4361 21.092zM97.9372 13.134C97.9372 12.214 98.1596 11.3937 98.6042 10.673 99.0642 9.937 99.6776 9.35433 100.444 8.925 101.211 8.49567 102.054 8.281 102.974 8.281S104.577 8.43433 105.021 8.741C105.481 9.03233 105.658 9.385 105.55 9.799 105.504 10.0137 105.412 10.1823 105.274 10.305 105.152 10.4123 105.006 10.4813 104.837 10.512 104.669 10.5427 104.485 10.535 104.285 10.489 103.304 10.2897 102.422 10.2743 101.64 10.443 100.858 10.6117 100.237 10.926 99.7772 11.386 99.3326 11.846 99.1102 12.4287 99.1102 13.134h-1.173zM97.9602 21C97.5922 21 97.3086 20.908 97.1092 20.724 96.9099 20.5247 96.8102 20.2333 96.8102 19.85V9.569C96.8102 9.201 96.9099 8.91733 97.1092 8.718 97.3086 8.51867 97.5922 8.419 97.9602 8.419 98.3436 8.419 98.6272 8.51867 98.8112 8.718 99.0106 8.902 99.1102 9.18567 99.1102 9.569V19.85C99.1102 20.218 99.0106 20.5017 98.8112 20.701 98.6272 20.9003 98.3436 21 97.9602 21z" fill="#fff"/><path d="M112.797 21.115C111.586 21.115 110.497 20.839 109.531 20.287 108.565 19.7197 107.798 18.953 107.231 17.987 106.679 17.021 106.403 15.9247 106.403 14.698 106.403 13.4867 106.671 12.398 107.208 11.432 107.76 10.466 108.504 9.707 109.439 9.155 110.374 8.58767 111.432 8.304 112.613 8.304c1.027.0 1.955.222329999999999 2.783.667C116.224 9.40033 116.891 9.97533 117.397 10.696V3.934c0-.276.083999999999989-.49067.253-.644C117.819 3.12133 118.033 3.037 118.294 3.037 118.555 3.037 118.769 3.12133 118.938 3.29c.168999999999997.15333.253.368.253.644V14.79C119.16 15.986 118.861 17.067 118.294 18.033 117.742 18.9837 116.983 19.735 116.017 20.287 115.066 20.839 113.993 21.115 112.797 21.115zm0-1.61C113.686 19.505 114.476 19.298 115.166 18.884 115.871 18.4547 116.423 17.8797 116.822 17.159 117.236 16.4383 117.443 15.618 117.443 14.698 117.443 13.7933 117.236 12.9807 116.822 12.26 116.423 11.524 115.871 10.949 115.166 10.535 114.476 10.121 113.686 9.914 112.797 9.914 111.923 9.914 111.133 10.121 110.428 10.535S109.163 11.524 108.749 12.26C108.335 12.9807 108.128 13.7933 108.128 14.698 108.128 15.618 108.335 16.4383 108.749 17.159 109.163 17.8797 109.723 18.4547 110.428 18.884 111.133 19.298 111.923 19.505 112.797 19.505zm15.262 1.61C126.832 21.115 125.736 20.839 124.77 20.287 123.804 19.735 123.045 18.976 122.493 18.01 121.941 17.044 121.665 15.9477 121.665 14.721 121.665 13.479 121.941 12.375 122.493 11.409 123.045 10.443 123.804 9.684 124.77 9.132 125.736 8.58 126.832 8.304 128.059 8.304 129.285 8.304 130.374 8.58 131.325 9.132 132.291 9.684 133.05 10.443 133.602 11.409 134.154 12.375 134.437 13.479 134.453 14.721 134.453 15.9477 134.169 17.044 133.602 18.01 133.05 18.976 132.291 19.735 131.325 20.287 130.374 20.839 129.285 21.115 128.059 21.115zm0-1.61C128.948 19.505 129.745 19.298 130.451 18.884 131.156 18.47 131.708 17.9027 132.107 17.182 132.505 16.4613 132.705 15.641 132.705 14.721S132.505 12.9807 132.107 12.26C131.708 11.524 131.156 10.949 130.451 10.535 129.745 10.121 128.948 9.914 128.059 9.914 127.169 9.914 126.372 10.121 125.667 10.535 124.961 10.949 124.402 11.524 123.988 12.26 123.589 12.9807 123.39 13.801 123.39 14.721S123.589 16.4613 123.988 17.182C124.402 17.9027 124.961 18.47 125.667 18.884 126.372 19.298 127.169 19.505 128.059 19.505zm14.45 1.61C141.298 21.115 140.217 20.839 139.266 20.287 138.331 19.7197 137.587 18.953 137.035 17.987 136.498 17.021 136.23 15.9323 136.23 14.721 136.23 13.4943 136.491 12.398 137.012 11.432 137.533 10.466 138.246 9.707 139.151 9.155 140.056 8.58767 141.098 8.304 142.279 8.304 143.214 8.304 144.073 8.488 144.855 8.856 145.652 9.224 146.35 9.776 146.948 10.512 147.117 10.696 147.178 10.8953 147.132 11.11 147.086 11.3093 146.956 11.4857 146.741 11.639 146.572 11.7617 146.381 11.8077 146.166 11.777 145.967 11.731 145.79 11.616 145.637 11.432 144.748 10.42 143.628 9.914 142.279 9.914 141.42 9.914 140.661 10.121 140.002 10.535 139.358 10.949 138.852 11.5163 138.484 12.237 138.131 12.9577 137.955 13.7857 137.955 14.721 137.955 15.641 138.147 16.4613 138.53 17.182 138.913 17.9027 139.45 18.47 140.14 18.884 140.83 19.298 141.62 19.505 142.509 19.505 143.107 19.505 143.651 19.4283 144.142 19.275 144.648 19.1063 145.093 18.8533 145.476 18.516 145.66 18.3627 145.852 18.2783 146.051 18.263 146.25 18.2477 146.434 18.309 146.603 18.447 146.787 18.6157 146.887 18.8073 146.902 19.022 146.933 19.2367 146.864 19.4207 146.695 19.574 145.576 20.6013 144.18 21.115 142.509 21.115zm11.46.0C153.064 21.115 152.167 20.9617 151.278 20.655 150.389 20.3483 149.668 19.8883 149.116 19.275 148.947 19.091 148.878 18.884 148.909 18.654S149.055 18.2247 149.254 18.056C149.469 17.9027 149.691 17.8413 149.921 17.872 150.151 17.9027 150.343 18.0023 150.496 18.171 150.864 18.6003 151.347 18.93 151.945 19.16 152.558 19.39 153.233 19.505 153.969 19.505 155.104 19.505 155.924 19.3133 156.43 18.93 156.936 18.5313 157.197 18.056 157.212 17.504 157.212 16.952 156.951 16.4997 156.43 16.147 155.909 15.779 155.05 15.4953 153.854 15.296 152.305 15.0507 151.171 14.6213 150.45 14.008 149.729 13.3947 149.369 12.6663 149.369 11.823 149.369 11.041 149.576 10.3893 149.99 9.868 150.404 9.34667 150.956 8.95567 151.646 8.695 152.336 8.43433 153.095 8.304 153.923 8.304 154.95 8.304 155.832 8.48033 156.568 8.833 157.319 9.18567 157.925 9.661 158.385 10.259 158.538 10.4583 158.6 10.6653 158.569 10.88 158.538 11.0947 158.416 11.271 158.201 11.409 158.017 11.5163 157.802 11.5547 157.557 11.524 157.327 11.478 157.128 11.363 156.959 11.179 156.576 10.7343 156.131 10.4123 155.625 10.213 155.119 9.99833 154.536 9.891 153.877 9.891 153.034 9.891 152.359 10.0673 151.853 10.42 151.347 10.7573 151.094 11.1867 151.094 11.708 151.094 12.0607 151.186 12.3673 151.37 12.628 151.569 12.8887 151.899 13.1187 152.359 13.318 152.834 13.5173 153.494 13.686 154.337 13.824 155.487 14.008 156.392 14.284 157.051 14.652 157.726 15.0047 158.201 15.4263 158.477 15.917 158.768 16.3923 158.914 16.9137 158.914 17.481 158.914 18.2017 158.699 18.838 158.27 19.39 157.856 19.9267 157.273 20.3483 156.522 20.655 155.786 20.9617 154.935 21.115 153.969 21.115z" fill="#fff"/></svg></div><div class="block sm:hidden"><svg width="84" height="25" viewBox="0 0 84 25" fill="none"><path d="M23.6087 10.9342C23.0202 10.5373 21.4744 10.3676 20.3501 10.6711 20.2896 9.5489 19.7119 8.60334 18.656 7.77841L18.2647 7.51537 18.0038 7.90993C17.4914 8.68895 17.2763 9.72711 17.3524 10.6711 17.413 11.2525 17.6148 11.9062 18.0038 12.3809c-1.4627.8506-2.8113.6576-8.78345.6576H.00209363C-.0250805 14.3903.192313 16.9904 1.8414 19.1064 2.02385 19.3399 2.22339 19.5663 2.44001 19.7843c1.34085 1.3463 3.36726 2.3331 6.39757 2.3362C13.4603 22.1244 17.4207 19.62 19.8299 13.5646 20.6226 13.5778 22.715 13.707 23.7391 11.7233 23.764 11.6898 24 11.1972 24 11.1972L23.6087 10.9342zM6.01846 9.53956H3.42604V12.1381H6.01846V9.53956zm3.34941.0H6.77545V12.1381H9.36787V9.53956zm3.34943.0H10.1249V12.1381h2.5924V9.53956zm3.3494.0H13.4743V12.1381h2.5924V9.53956zm-13.39843.0H.0766285V12.1381H2.66905L2.66827 9.53956zm3.34941-3.2826H3.42526V8.85549H6.01768V6.25696zm3.34941.0H6.77468V8.85549H9.36709V6.25696zm3.34941.0H10.1241V8.85549h2.5924V6.25696zm0-3.28259H10.1241V5.57289h2.5924V2.97437z" fill="#fff"/><path d="M36.774 21.6394c-1.196.0-2.277-.276-3.243-.827999999999999C32.5803 20.244 31.8213 19.4774 31.254 18.5114 30.702 17.5454 30.426 16.4567 30.426 15.2454c0-1.2114.253-2.2924.759-3.243C31.7063 11.0364 32.4117 10.2774 33.301 9.72536 34.1903 9.15803 35.1947 8.87436 36.314 8.87436 37.2187 8.87436 38.0543 9.06603 38.821 9.44936 39.5877 9.81736 40.2317 10.3234 40.753 10.9674V4.75736C40.753 4.4047 40.8603 4.12103 41.075 3.90636 41.305 3.6917 41.5887 3.58436 41.926 3.58436 42.2787 3.58436 42.5623 3.6917 42.777 3.90636 42.9917 4.12103 43.099 4.4047 43.099 4.75736V15.2454C43.099 16.4567 42.8153 17.5454 42.248 18.5114 41.696 19.4774 40.9447 20.244 39.994 20.8114 39.0433 21.3634 37.97 21.6394 36.774 21.6394zm0-2.07C37.556 19.5694 38.2537 19.3854 38.867 19.0174 39.4803 18.634 39.9633 18.1127 40.316 17.4534 40.6687 16.794 40.845 16.058 40.845 15.2454 40.845 14.4174 40.6687 13.6814 40.316 13.0374 39.9633 12.3934 39.4803 11.8874 38.867 11.5194 38.2537 11.136 37.556 10.9444 36.774 10.9444 36.0073 10.9444 35.3097 11.136 34.681 11.5194 34.0677 11.8874 33.577 12.3934 33.209 13.0374 32.8563 13.6814 32.68 14.4174 32.68 15.2454 32.68 16.058 32.8563 16.794 33.209 17.4534 33.577 18.1127 34.0677 18.634 34.681 19.0174 35.3097 19.3854 36.0073 19.5694 36.774 19.5694zm15.1719 2.07c-1.242.0-2.3384-.2684-3.289-.805C47.7062 20.2824 46.9549 19.531 46.4029 18.5804 45.8662 17.6144 45.5979 16.5104 45.5979 15.2684c0-1.2574.268299999999996-2.3614.805-3.312C46.9549 10.9904 47.7062 10.239 48.6569 9.70236 49.6075 9.15036 50.7039 8.87436 51.9459 8.87436c1.2266.0 2.3153.276 3.266.828000000000001C56.1625 10.239 56.9062 10.9904 57.4429 11.9564 57.9949 12.907 58.2709 14.011 58.2709 15.2684c0 1.242-.2684 2.346-.805 3.312C56.9292 19.531 56.1855 20.2824 55.2349 20.8344c-.950700000000005.5366-2.047.805-3.289.805zm0-2.07C52.7432 19.5694 53.4485 19.3854 54.0619 19.0174 54.6752 18.6494 55.1505 18.1434 55.4879 17.4994 55.8405 16.8554 56.0169 16.1117 56.0169 15.2684 56.0169 14.425 55.8405 13.6814 55.4879 13.0374 55.1505 12.378 54.6752 11.8644 54.0619 11.4964c-.613399999999999-.368-1.3187-.552-2.116-.552C51.1485 10.9444 50.4432 11.1284 49.8299 11.4964 49.2165 11.8644 48.7335 12.378 48.3809 13.0374 48.0282 13.6814 47.8519 14.425 47.8519 15.2684 47.8519 16.1117 48.0282 16.8554 48.3809 17.4994 48.7335 18.1434 49.2165 18.6494 49.8299 19.0174 50.4432 19.3854 51.1485 19.5694 51.9459 19.5694zm14.5205 2.07C65.2397 21.6394 64.1434 21.3634 63.1774 20.8114 62.2267 20.244 61.4754 19.485 60.9234 18.5344 60.3867 17.5684 60.1184 16.4797 60.1184 15.2684c0-1.242.268299999999996-2.346.805-3.312C61.46 10.9904 62.196 10.239 63.1314 9.70236 64.0667 9.15036 65.14 8.87436 66.3514 8.87436 67.256 8.87436 68.084 9.0507 68.8354 9.40336 69.5867 9.7407 70.2614 10.2544 70.8594 10.9444 71.0741 11.1897 71.1507 11.4427 71.0894 11.7034 71.0281 11.964 70.8594 12.194 70.5834 12.3934 70.3687 12.5467 70.1311 12.6004 69.8704 12.5544 69.6097 12.493 69.372 12.355 69.1574 12.1404 68.406 11.343 67.4707 10.9444 66.3514 10.9444 65.5694 10.9444 64.8794 11.1284 64.2814 11.4964 63.6834 11.849 63.2157 12.3474 62.8784 12.9914c-.337400000000002.644-.506 1.403-.506 2.277C62.3724 16.0964 62.541 16.8324 62.8784 17.4764 63.231 18.1204 63.714 18.634 64.3274 19.0174 64.9407 19.3854 65.6537 19.5694 66.4664 19.5694 67.0031 19.5694 67.4707 19.508 67.8694 19.3854 68.2834 19.2474 68.6591 19.0404 68.9964 18.7644 69.2417 18.565 69.4947 18.4577 69.7554 18.4424 70.0161 18.4117 70.2461 18.4807 70.4454 18.6494 70.706 18.864 70.8517 19.1094 70.8824 19.3854 70.913 19.646 70.821 19.8837 70.6064 20.0984 69.5024 21.1257 68.1224 21.6394 66.4664 21.6394zm11.6865.0C77.0795 21.6394 76.0829 21.4784 75.1629 21.1564 74.2582 20.819 73.5529 20.3974 73.0469 19.8914 72.8169 19.646 72.7172 19.37 72.7479 19.0634 72.7939 18.7414 72.9472 18.4807 73.2079 18.2814 73.5145 18.036 73.8135 17.9364 74.1049 17.9824 74.4115 18.013 74.6722 18.1434 74.8869 18.3734 75.1475 18.6647 75.5615 18.9407 76.1289 19.2014 76.7115 19.4467 77.3555 19.5694 78.0609 19.5694 78.9502 19.5694 79.6249 19.4237 80.0849 19.1324 80.5602 18.841 80.8055 18.4654 80.8209 18.0054 80.8362 17.5454 80.6139 17.1467 80.1539 16.8094 79.7092 16.472 78.8889 16.196 77.6929 15.9814 76.1442 15.6747 75.0172 15.2147 74.3119 14.6014 73.6219 13.988 73.2769 13.2367 73.2769 12.3474 73.2769 11.5654 73.5069 10.9214 73.9669 10.4154 74.4269 9.89403 75.0172 9.5107 75.7379 9.26536 76.4585 9.0047 77.2099 8.87436 77.9919 8.87436 79.0039 8.87436 79.9009 9.03536 80.6829 9.35736 81.4649 9.67936 82.0859 10.124 82.5459 10.6914 82.7605 10.9367 82.8602 11.1974 82.8449 11.4734 82.8295 11.734 82.6992 11.9564 82.4539 12.1404 82.2085 12.309 81.9172 12.3627 81.5799 12.3014 81.2425 12.24 80.9589 12.102 80.7289 11.8874 80.3455 11.5194 79.9315 11.2664 79.4869 11.1284 79.0422 10.9904 78.5285 10.9214 77.9459 10.9214 77.2712 10.9214 76.6962 11.0364 76.2209 11.2664 75.7609 11.4964 75.5309 11.8337 75.5309 12.2784 75.5309 12.5544 75.5999 12.8074 75.7379 13.0374 75.8912 13.252 76.1825 13.4514 76.6119 13.6354 77.0412 13.804 77.6699 13.9727 78.4979 14.1414 79.6479 14.3714 80.5525 14.6627 81.2119 15.0154 81.8865 15.368 82.3695 15.782 82.6609 16.2574 82.9522 16.7174 83.0979 17.254 83.0979 17.8674 83.0979 18.5727 82.9062 19.209 82.5229 19.7764 82.1549 20.3437 81.6029 20.796 80.8669 21.1334 80.1462 21.4707 79.2415 21.6394 78.1529 21.6394z" fill="#fff"/></svg></div></a></div><nav class="mt-1 hidden md:block"><ul class="flex text-sm md:text-base lg:gap-4"><li class="border-b-4 border-transparent hover:border-white/20"><a class="block px-2 py-1 whitespace-nowrap" href=/get-started/>Get started</a></li><li class="border-b-4 border-transparent hover:border-white/20"><a class="block px-2 py-1 whitespace-nowrap" href=/guides/>Guides</a></li><li class="border-b-4 border-transparent hover:border-white/20"><a class="block px-2 py-1 whitespace-nowrap" href=/manuals/>Manuals</a></li><li class=border-b-4><a class="block px-2 py-1 whitespace-nowrap" href=/reference/>Reference</a></li></ul></nav></div><div class="flex min-w-0 items-center gap-4 flex-grow justify-end"><a href=/search class=sm:hidden><span class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M378-329q-108.16.0-183.08-75Q120-479 120-585t75-181 181.5-75 181 75T632-584.85Q632-542 618-502t-42 75l242 240q9 8.56 9 21.78T818-143t-22.22 9-21.78-9L533-384q-30 26-69.96 40.5Q423.08-329 378-329zm-1-60q81.25.0 138.13-57.5Q572-504 572-585t-56.87-138.5Q458.25-781 377-781q-82.08.0-139.54 57.5T180-585t57.46 138.5T377-389z"/></svg></span></a><div x-ref=searchBarRef x-data="{ open: false }" @click.outside="open = false;" @keyup.escape.window="open = false" id=search-bar class="hidden min-w-0 sm:flex relative bg-white/10 rounded items-center p-2 sm:w-full xl:w-[400px]"><svg width="25" height="25" viewBox="0 0 25 25" fill="none"><mask id="mask0_200_9677" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="2" y="0" width="21" height="23"><path d="M21.2461 21.4956l-4.35-4.35m2.35-5.65c0 4.4183-3.5817 8-8 8-4.41828.0-8.00001-3.5817-8.00001-8 0-4.41827 3.58173-7.99999 8.00001-7.99999" stroke="#677285" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M16.7461 1.84082 17.5306 3.40974C17.796 3.94072 17.9288 4.2062 18.1061 4.43627 18.2635 4.64041 18.4465 4.82343 18.6506 4.98079c.2301.17734.4956.31008 1.0266.57557l1.5689.78446-1.5689.78446C19.1462 7.39077 18.8807 7.52351 18.6506 7.70085 18.4465 7.85821 18.2635 8.04123 18.1061 8.24537 17.9288 8.47544 17.796 8.74093 17.5306 9.2719L16.7461 10.8408 15.9616 9.2719C15.6961 8.74092 15.5634 8.47544 15.3861 8.24537 15.2287 8.04123 15.0457 7.85821 14.8415 7.70085c-.23-.17734-.4955-.31008-1.0265-.57557l-1.5689-.78446 1.5689-.78446C14.346 5.29087 14.6115 5.15813 14.8415 4.98079 15.0457 4.82343 15.2287 4.64041 15.3861 4.43627 15.5634 4.2062 15.6961 3.94072 15.9616 3.40974L16.7461 1.84082z" stroke="#677285" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></mask><g mask="url(#mask0_200_9677)"><rect x=".426636" y=".495605" width="24" height="24" fill="#fff"/></g></svg> <input x-ref=searchBarInput type=search id=search-bar-input @focus="open = true;" @keyup.enter.prevent="window.location.href = '/search/?q=' + $event.target.value;" @keyup.escape.prevent="open = false;" @keydown.window="(e) => { switch(e.key) { case 'k': if (e.metaKey || e.ctrlKey) { e.preventDefault(); $el.focus(); } break; } }" class="flex-grow px-2 bg-transparent min-w-0 text-white placeholder:text-white outline-none" placeholder=Search tabindex=0><div x-cloak :class="open && 'hidden'" class="hidden lg:flex border px-1 text-sm border-white rounded items-center"><div class=-mt-0.5><span x-show="navigator.platform == 'MacIntel'" class="icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M249.9-120q-53.9.0-91.9-38.1t-38-92 38.07-91.9T250-380h70v-2e2h-70q-53.86.0-91.93-38.1t-38.07-92 38.1-91.9 92-38 91.9 38.07T380-710v70h2e2v-70q0-53.86 38.1-91.93t92-38.07 91.9 38.1 38 92T801.93-618q-38.07 38-91.93 38h-70v2e2h70q53.86.0 91.93 38.1t38.07 92T801.9-158q-38.1 38-92 38T618-158.07 580-250v-70H380v70q0 53.86-38.1 91.93t-92 38.07zm-.02-60q29.12.0 49.62-20.42Q320-220.83 320-250v-70h-70q-29.17.0-49.58 20.38Q180-279.24 180-250.12t20.38 49.62 49.5 20.5zm460 0q29.12.0 49.62-20.38t20.5-49.5-20.42-49.62Q739.17-320 710-320h-70v70q0 29.17 20.38 49.58Q680.76-180 709.88-180zM380-380h2e2v-2e2H380v2e2zM250-640h70v-70q0-29.17-20.38-49.58Q279.24-780 250.12-780t-49.62 20.38-20.5 49.5 20.42 49.62Q220.83-640 250-640zm390 0h70q29.17.0 49.58-20.38Q780-680.76 780-709.88t-20.38-49.62-49.5-20.5-49.62 20.42Q640-739.17 640-710v70z"/></svg></span> <span x-show="navigator.platform != 'MacIntel'" class="icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M480-675 263-459q-9 9-21 9t-21-9-9-21 9-21l238-238q9-9 21-9t21 9l238 238q9 9 9 21t-9 21-21 9-21-9L480-675z"/></svg></span></div><span>K</span></div><div x-cloak :class="open || 'hidden'"><button @click="$refs.searchBarInput.value = ''; open = false" class="text-white hover:text-white"> <span class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M480-438 270-228q-9 9-21 9t-21-9-9-21 9-21l210-210-210-210q-9-9-9-21t9-21 21-9 21 9l210 210 210-210q9-9 21-9t21 9 9 21-9 21L522-480l210 210q9 9 9 21t-9 21-21 9-21-9L480-438z"/></svg></span></button></div><div x-show=open x-cloak class="absolute px-6 py-4 right-0 w-screen max-w-xl top-full bg-background-light dark:bg-background-dark rounded shadow-lg z-50"><div id=search-bar-results><div class="p-2 text-gray-light dark:text-gray-dark">Start typing to search… or try <button @click="open=false" class="open-kapa-widget link">Ask AI</button></div></div></div><script type=module> window.addEventListener("load", async function () { const pagefind = await import("/pagefind/pagefind.js"); await pagefind.options({ ranking: { termFrequency: 0.2, pageLength: 0.75, termSaturation: 1.4, termSimilarity: 6.0, }, }); const searchBarInput = document.querySelector("#search-bar-input"); const searchBarResults = document.querySelector( "#search-bar-results", ); async function search(e) { const query = e.target.value; if (query === "") { searchBarResults.innerHTML = `\u003cdiv class=\u0022p-2 text-gray-light dark:text-gray-dark\u0022\u003eStart typing to search… or try \u003cbutton @click=\u0022open=false\u0022 class=\u0022open-kapa-widget link\u0022\u003eAsk AI\u003c\/button\u003e\u003c\/div\u003e`; return; } const search = await pagefind.debouncedSearch(query); if (search === null) { return; } else { const resultsLength = search.results.length const resultsData = await Promise.all(search.results.slice(0, 5).map(r => r.data())); const results = resultsData.map((item, index) => ({...item, index: index + 1})); if (query) { searchBarResults.classList.remove("hidden"); } else { searchBarResults.classList.add("hidden"); } let resultsHTML = `<div class="p-2 text-gray-light dark:text-gray-dark">${resultsLength} results</div>`; resultsHTML += results .map((item) => { return `<div class="p-2"> <div class="flex flex-col"> <a class="link" href="${item.url}" data-query="${query}" data-index="${item.index}">${item.meta.title}</a> <p class="text-black dark:text-white overflow-hidden">…${item.excerpt}…</p> </div> </div>`; }) .join(""); if (resultsLength > 5) { resultsHTML += `<div class="w-fit ml-auto px-4 py-2"><a href="/search/?q=${query}" class="link">Show all results</a></div>`; } searchBarResults.innerHTML = resultsHTML; } } searchBarInput.addEventListener("input", search); if (window.heap !== undefined) { searchBarResults.addEventListener('click', function (event) { if (event.target.tagName === 'A' && event.target.closest('.link')) { const searchQuery = event.target.getAttribute('data-query'); const resultIndex = event.target.getAttribute('data-index'); const url = new URL(event.target.href); const properties = { docs_search_target_path: url.pathname, docs_search_target_title: event.target.textContent, docs_search_query_text: searchQuery, docs_search_target_index: resultIndex, docs_search_source_path: window.location.pathname, docs_search_source_title: document.title, }; heap.track("Docs - Search - Click - Result Link", properties); } }); } }); </script></div><button @click="open = false" class="dark:text-white py-1 px-2 rounded open-kapa-widget flex gap-1 items-center hover:bg-white/20 transition"> <span>Ask AI</span> <img src=https://docs.docker.com/images/ai-stars.svg alt="AI Stars"></button></div></div></header><main class="relative flex w-full max-w-[1920px]"><div style=scroll-behavior:smooth x-data x-init="$nextTick(() => { const container = $el; // The div with overflow const item = document.getElementById('sidebar-current-page') if (item) { const containerTop = container.scrollTop; const containerBottom = containerTop + container.clientHeight; const itemTop = item.offsetTop - container.offsetTop; const itemBottom = itemTop + item.offsetHeight; // Scroll only if the item is out of view if (itemBottom > containerBottom - 200) { container.scrollTop = itemTop - (container.clientHeight / 2 - item.offsetHeight / 2); } } })" class="md:h-[calc(100vh-64px)] fixed md:sticky top-0 md:top-16 z-40 hidden h-screen flex-none overflow-y-auto overflow-x-hidden bg-background-light dark:bg-gray-dark-100 w-full md:z-auto md:block md:w-[300px]" :class="{ 'hidden': ! $store.showSidebar }"><div class="fixed bg-black/50 md:hidden" x-show=$store.showSidebar @click="openSidebar = false" x-transition.opacity></div><div class="z-50 w-full bg-background-light p-4 dark:bg-gray-dark-100 md:block md:w-[300px]"><button class="my-4 md:hidden" @click="$store.showSidebar = false"> <span class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m275-450 147 147q9 9 8.5 21t-9.5 21-21 9-21-9L181-459q-9-9-9-21t9-21l199-199q9-9 21-9t21 9 9 21.5-9 21.5L275-510h496q13 0 21.5 8.5T801-480t-8.5 21.5T771-450H275z"/></svg></span> Back</button><div class="py-2 px-4" x-data="{ expanded: false }"><div class="flex w-full items-center justify-between"><a class="hover:text-blue-light dark:hover:text-blue-dark" href=https://docs.docker.com/reference/><span class="pr-2 icon-sm icon-svg"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M140-160q-24 0-42-18t-18-42v-520q0-24 18-42t42-18h680q24 0 42 18t18 42v520q0 24-18 42t-42 18H140zm0-60h680v-436H140v436zm221-218-83-83q-9-9-8.5-21t9.5-21 21-9 21 9l104 104q9 9 9 21t-9 21L321-313q-9 9-21 9t-21-9-9-21 9-21l82-83zm159 150q-13 0-21.5-8.5T490-318t8.5-21.5T520-348h160q13 0 21.5 8.5T710-318t-8.5 21.5T680-288H520z"/></svg></span>Reference</a> <button @click="expanded = !expanded" class="rounded hover:bg-gray-light-300 hover:dark:bg-gray-dark-300"> <span x-show="! expanded" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span x-cloak x-show=expanded class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul x-cloak x-show=expanded class="pt-4 space-y-4"><li><a class="hover:text-blue-light dark:hover:text-blue-dark" href=/get-started/><span class="pr-2 icon-sm icon-svg"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M479.87-325q-5.87.0-10.87-2t-10-7L308-485q-9-9.27-8.5-21.64.5-12.36 9.11-21.36 9.39-9 21.89-9t21.5 9l98 99v-341q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v341l99-99q8.8-9 20.9-8.5t21.49 9.5q8.61 9 8.61 21.5t-9 21.5L501-334q-5 5-10.13 7-5.14 2-11 2zM220-160q-24 0-42-18t-18-42v-113q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v113h520v-113q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v113q0 24-18 42t-42 18H220z"/></svg></span>Get started</a></li><li><a class="hover:text-blue-light dark:hover:text-blue-dark" href=/guides/><span class="pr-2 icon-sm icon-svg"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h6e2q24 0 42 18t18 42v6e2q0 24-18 42t-42 18H180zm3e2-660v252q0 9 7.5 13.5t15.5-.5l60-36q8-5 15-5t15 5l60 36q8 5 15.5.5T676-528v-252H480z"/></svg></span>Guides</a></li><li><a class="hover:text-blue-light dark:hover:text-blue-dark" href=/manuals/><span class="pr-2 icon-sm icon-svg"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M349-250h262q12.75.0 21.38-8.68 8.62-8.67 8.62-21.5.0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H349q-12.75.0-21.37 8.68-8.63 8.67-8.63 21.5.0 12.82 8.63 21.32 8.62 8.5 21.37 8.5zm0-170h262q12.75.0 21.38-8.68 8.62-8.67 8.62-21.5.0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H349q-12.75.0-21.37 8.68-8.63 8.67-8.63 21.5.0 12.82 8.63 21.32 8.62 8.5 21.37 8.5zM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h336q12.44.0 23.72 5T599-862l183 183q8 8 13 19.28t5 23.72v496q0 24-18 42t-42 18H220zm331-584q0 12.75 8.63 21.37Q568.25-634 581-634h159L551-820v156z"/></svg></span>Manuals</a></li></ul></div><hr class="m-2 text-gray-light-200 dark:text-gray-dark-300"><nav class="md:text-sm flex flex-col"><div class="block py-4 md:hidden text-gray-light dark:text-gray-dark">This section</div><ul><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><button @click="expanded = !expanded" class="w-full text-left select-none hover:text-blue-light hover:dark:text-blue-dark"> CLI reference</button></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/>docker</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/buildx/build/ title="docker build">docker build</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/build-legacy/ title="docker build (legacy builder)">docker build (legacy builder)</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/builder/>docker builder</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/builder/prune/ title="docker builder prune">docker builder prune</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/buildx/>docker buildx</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/bake/ title="docker buildx bake">docker buildx bake</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/build/ title="docker buildx build">docker buildx build</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/create/ title="docker buildx create">docker buildx create</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/buildx/debug/>docker buildx debug</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/debug/build/ title="docker buildx debug build">docker buildx debug build</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/du/ title="docker buildx du">docker buildx du</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/buildx/history/>docker buildx history</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/buildx/history/inspect/>docker buildx history inspect</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/inspect/attachment/ title="docker buildx history inspect attachment">docker buildx history inspect attachment</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/logs/ title="docker buildx history logs">docker buildx history logs</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/ls/ title="docker buildx history ls">docker buildx history ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/open/ title="docker buildx history open">docker buildx history open</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/rm/ title="docker buildx history rm">docker buildx history rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/history/trace/ title="docker buildx history trace">docker buildx history trace</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/buildx/imagetools/>docker buildx imagetools</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/imagetools/create/ title="docker buildx imagetools create">docker buildx imagetools create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/imagetools/inspect/ title="docker buildx imagetools inspect">docker buildx imagetools inspect</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/inspect/ title="docker buildx inspect">docker buildx inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/ls/ title="docker buildx ls">docker buildx ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/prune/ title="docker buildx prune">docker buildx prune</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/rm/ title="docker buildx rm">docker buildx rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/stop/ title="docker buildx stop">docker buildx stop</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/use/ title="docker buildx use">docker buildx use</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/buildx/version/ title="docker buildx version">docker buildx version</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/checkpoint/>docker checkpoint</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/checkpoint/create/ title="docker checkpoint create">docker checkpoint create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/checkpoint/ls/ title="docker checkpoint ls">docker checkpoint ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/checkpoint/rm/ title="docker checkpoint rm">docker checkpoint rm</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/compose/>docker compose</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/compose/alpha/>docker compose alpha</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/alpha/dry-run/ title="docker compose alpha dry-run">docker compose alpha dry-run</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/alpha/publish/ title="docker compose alpha publish">docker compose alpha publish</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/alpha/scale/ title="docker compose alpha scale">docker compose alpha scale</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/alpha/viz/ title="docker compose alpha viz">docker compose alpha viz</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/build/ title="docker compose build">docker compose build</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/config/ title="docker compose config">docker compose config</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/cp/ title="docker compose cp">docker compose cp</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/create/ title="docker compose create">docker compose create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/down/ title="docker compose down">docker compose down</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/events/ title="docker compose events">docker compose events</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/exec/ title="docker compose exec">docker compose exec</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/images/ title="docker compose images">docker compose images</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/kill/ title="docker compose kill">docker compose kill</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/logs/ title="docker compose logs">docker compose logs</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/ls/ title="docker compose ls">docker compose ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/pause/ title="docker compose pause">docker compose pause</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/port/ title="docker compose port">docker compose port</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/ps/ title="docker compose ps">docker compose ps</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/pull/ title="docker compose pull">docker compose pull</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/push/ title="docker compose push">docker compose push</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/restart/ title="docker compose restart">docker compose restart</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/rm/ title="docker compose rm">docker compose rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/run/ title="docker compose run">docker compose run</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/start/ title="docker compose start">docker compose start</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/stop/ title="docker compose stop">docker compose stop</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/top/ title="docker compose top">docker compose top</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/unpause/ title="docker compose unpause">docker compose unpause</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/up/ title="docker compose up">docker compose up</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/version/ title="docker compose version">docker compose version</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/wait/ title="docker compose wait">docker compose wait</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/compose/watch/ title="docker compose watch">docker compose watch</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/config/>docker config</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/config/create/ title="docker config create">docker config create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/config/inspect/ title="docker config inspect">docker config inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/config/ls/ title="docker config ls">docker config ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/config/rm/ title="docker config rm">docker config rm</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/container/>docker container</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/attach/ title="docker container attach">docker container attach</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/commit/ title="docker container commit">docker container commit</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/cp/ title="docker container cp">docker container cp</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/create/ title="docker container create">docker container create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/diff/ title="docker container diff">docker container diff</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/exec/ title="docker container exec">docker container exec</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/export/ title="docker container export">docker container export</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/inspect/ title="docker container inspect">docker container inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/kill/ title="docker container kill">docker container kill</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/logs/ title="docker container logs">docker container logs</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/ls/ title="docker container ls">docker container ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/pause/ title="docker container pause">docker container pause</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/port/ title="docker container port">docker container port</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/prune/ title="docker container prune">docker container prune</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/rename/ title="docker container rename">docker container rename</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/restart/ title="docker container restart">docker container restart</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/rm/ title="docker container rm">docker container rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/run/ title="docker container run">docker container run</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/start/ title="docker container start">docker container start</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/stats/ title="docker container stats">docker container stats</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/stop/ title="docker container stop">docker container stop</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/top/ title="docker container top">docker container top</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/unpause/ title="docker container unpause">docker container unpause</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/update/ title="docker container update">docker container update</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/container/wait/ title="docker container wait">docker container wait</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/context/>docker context</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/create/ title="docker context create">docker context create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/export/ title="docker context export">docker context export</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/import/ title="docker context import">docker context import</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/inspect/ title="docker context inspect">docker context inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/ls/ title="docker context ls">docker context ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/rm/ title="docker context rm">docker context rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/show/ title="docker context show">docker context show</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/update/ title="docker context update">docker context update</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/context/use/ title="docker context use">docker context use</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/debug/ title="docker debug">docker debug</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/desktop/>docker desktop (Beta)</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/desktop/engine/>docker desktop engine</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/engine/ls/ title="docker desktop engine ls">docker desktop engine ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/engine/use/ title="docker desktop engine use">docker desktop engine use</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/restart/ title="docker desktop restart">docker desktop restart</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/start/ title="docker desktop start">docker desktop start</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/status/ title="docker desktop status">docker desktop status</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/stop/ title="docker desktop stop">docker desktop stop</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/desktop/update/ title="docker desktop update">docker desktop update</a></li></ul></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/container/exec/ title="docker exec">docker exec</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/image/>docker image</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/history/ title="docker image history">docker image history</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/import/ title="docker image import">docker image import</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/inspect/ title="docker image inspect">docker image inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/load/ title="docker image load">docker image load</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/ls/ title="docker image ls">docker image ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/prune/ title="docker image prune">docker image prune</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/pull/ title="docker image pull">docker image pull</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/push/ title="docker image push">docker image push</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/rm/ title="docker image rm">docker image rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/save/ title="docker image save">docker image save</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/image/tag/ title="docker image tag">docker image tag</a></li></ul></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/image/ls/ title="docker images">docker images</a></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/system/info/ title="docker info">docker info</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/init/ title="docker init">docker init</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/inspect/ title="docker inspect">docker inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/login/ title="docker login">docker login</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/logout/ title="docker logout">docker logout</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/manifest/>docker manifest</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/manifest/annotate/ title="docker manifest annotate">docker manifest annotate</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/manifest/create/ title="docker manifest create">docker manifest create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/manifest/inspect/ title="docker manifest inspect">docker manifest inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/manifest/push/ title="docker manifest push">docker manifest push</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/manifest/rm/ title="docker manifest rm">docker manifest rm</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/network/>docker network</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/connect/ title="docker network connect">docker network connect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/create/ title="docker network create">docker network create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/disconnect/ title="docker network disconnect">docker network disconnect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/inspect/ title="docker network inspect">docker network inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/ls/ title="docker network ls">docker network ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/prune/ title="docker network prune">docker network prune</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/network/rm/ title="docker network rm">docker network rm</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/node/>docker node</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/demote/ title="docker node demote">docker node demote</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/inspect/ title="docker node inspect">docker node inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/ls/ title="docker node ls">docker node ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/promote/ title="docker node promote">docker node promote</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/ps/ title="docker node ps">docker node ps</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/rm/ title="docker node rm">docker node rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/node/update/ title="docker node update">docker node update</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/plugin/>docker plugin</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/create/ title="docker plugin create">docker plugin create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/disable/ title="docker plugin disable">docker plugin disable</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/enable/ title="docker plugin enable">docker plugin enable</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/inspect/ title="docker plugin inspect">docker plugin inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/install/ title="docker plugin install">docker plugin install</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/ls/ title="docker plugin ls">docker plugin ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/push/ title="docker plugin push">docker plugin push</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/rm/ title="docker plugin rm">docker plugin rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/set/ title="docker plugin set">docker plugin set</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/plugin/upgrade/ title="docker plugin upgrade">docker plugin upgrade</a></li></ul></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/container/ls/ title="docker ps">docker ps</a></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/image/pull/ title="docker pull">docker pull</a></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/image/push/ title="docker push">docker push</a></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/cli/docker/container/run/ title="docker run">docker run</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/scout/>docker scout</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/scout/attestation/>docker scout attestation</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/attestation/add/ title="docker scout attestation add">docker scout attestation add</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/scout/cache/>docker scout cache</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/cache/df/ title="docker scout cache df">docker scout cache df</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/cache/prune/ title="docker scout cache prune">docker scout cache prune</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/compare/ title="docker scout compare">docker scout compare</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/config/ title="docker scout config">docker scout config</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/cves/ title="docker scout cves">docker scout cves</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/enroll/ title="docker scout enroll">docker scout enroll</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/environment/ title="docker scout environment">docker scout environment</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/scout/integration/>docker scout integration</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/integration/configure/ title="docker scout integration configure">docker scout integration configure</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/integration/delete/ title="docker scout integration delete">docker scout integration delete</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/integration/list/ title="docker scout integration list">docker scout integration list</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/policy/ title="docker scout policy">docker scout policy</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/push/ title="docker scout push">docker scout push</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/quickview/ title="docker scout quickview">docker scout quickview</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/recommendations/ title="docker scout recommendations">docker scout recommendations</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/scout/repo/>docker scout repo</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/repo/disable/ title="docker scout repo disable">docker scout repo disable</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/repo/enable/ title="docker scout repo enable">docker scout repo enable</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/repo/list/ title="docker scout repo list">docker scout repo list</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/sbom/ title="docker scout sbom">docker scout sbom</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/stream/ title="docker scout stream">docker scout stream</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/version/ title="docker scout version">docker scout version</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/scout/watch/ title="docker scout watch">docker scout watch</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/search/ title="docker search">docker search</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/secret/>docker secret</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/secret/create/ title="docker secret create">docker secret create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/secret/inspect/ title="docker secret inspect">docker secret inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/secret/ls/ title="docker secret ls">docker secret ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/secret/rm/ title="docker secret rm">docker secret rm</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/service/>docker service</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/create/ title="docker service create">docker service create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/inspect/ title="docker service inspect">docker service inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/logs/ title="docker service logs">docker service logs</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/ls/ title="docker service ls">docker service ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/ps/ title="docker service ps">docker service ps</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/rm/ title="docker service rm">docker service rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/rollback/ title="docker service rollback">docker service rollback</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/scale/ title="docker service scale">docker service scale</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/service/update/ title="docker service update">docker service update</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/stack/>docker stack</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/config/ title="docker stack config">docker stack config</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/deploy/ title="docker stack deploy">docker stack deploy</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/ls/ title="docker stack ls">docker stack ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/ps/ title="docker stack ps">docker stack ps</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/rm/ title="docker stack rm">docker stack rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/stack/services/ title="docker stack services">docker stack services</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/swarm/>docker swarm</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/ca/ title="docker swarm ca">docker swarm ca</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/init/ title="docker swarm init">docker swarm init</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/join/ title="docker swarm join">docker swarm join</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/join-token/ title="docker swarm join-token">docker swarm join-token</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/leave/ title="docker swarm leave">docker swarm leave</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/unlock/ title="docker swarm unlock">docker swarm unlock</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/unlock-key/ title="docker swarm unlock-key">docker swarm unlock-key</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/swarm/update/ title="docker swarm update">docker swarm update</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/system/>docker system</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/system/df/ title="docker system df">docker system df</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/system/events/ title="docker system events">docker system events</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/system/info/ title="docker system info">docker system info</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/system/prune/ title="docker system prune">docker system prune</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/trust/>docker trust</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/inspect/ title="docker trust inspect">docker trust inspect</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/trust/key/>docker trust key</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/key/generate/ title="docker trust key generate">docker trust key generate</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/key/load/ title="docker trust key load">docker trust key load</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/revoke/ title="docker trust revoke">docker trust revoke</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/sign/ title="docker trust sign">docker trust sign</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/trust/signer/>docker trust signer</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/signer/add/ title="docker trust signer add">docker trust signer add</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/trust/signer/remove/ title="docker trust signer remove">docker trust signer remove</a></li></ul></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/version/ title="docker version">docker version</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/cli/docker/volume/>docker volume</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/create/ title="docker volume create">docker volume create</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/inspect/ title="docker volume inspect">docker volume inspect</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/ls/ title="docker volume ls">docker volume ls</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/prune/ title="docker volume prune">docker volume prune</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/rm/ title="docker volume rm">docker volume rm</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/docker/volume/update/ title="docker volume update">docker volume update</a></li></ul></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/cli/dockerd/ title=dockerd>dockerd</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><button @click="expanded = !expanded" class="w-full text-left select-none hover:text-blue-light hover:dark:text-blue-dark"> API reference</button></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/api/engine/>Docker Engine API</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/api/engine/sdk/>SDK</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/sdk/examples/ title=Examples>Examples</a></li></ul></li><li class="px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=/reference/api/engine/latest/ title=Latest>Latest</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><button @click="expanded = !expanded" class="w-full text-left select-none hover:text-blue-light hover:dark:text-blue-dark"> API reference by version</button></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.48/ title=v1.48>v1.48</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.47/ title=v1.47>v1.47</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.46/ title=v1.46>v1.46</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.45/ title=v1.45>v1.45</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.44/ title=v1.44>v1.44</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.43/ title=v1.43>v1.43</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.42/ title=v1.42>v1.42</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.41/ title=v1.41>v1.41</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.40/ title=v1.40>v1.40</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.39/ title=v1.39>v1.39</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.38/ title=v1.38>v1.38</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.37/ title=v1.37>v1.37</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.36/ title=v1.36>v1.36</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.35/ title=v1.35>v1.35</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.34/ title=v1.34>v1.34</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.33/ title=v1.33>v1.33</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.32/ title=v1.32>v1.32</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.31/ title=v1.31>v1.31</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.30/ title=v1.30>v1.30</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.29/ title=v1.29>v1.29</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.28/ title=v1.28>v1.28</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.27/ title=v1.27>v1.27</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.26/ title=v1.26>v1.26</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.25/ title=v1.25>v1.25</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version/v1.24/ title="Engine API v1.24">Engine API v1.24</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/engine/version-history/ title="Engine API version history">Engine API version history</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><button @click="expanded = !expanded" class="w-full text-left select-none hover:text-blue-light hover:dark:text-blue-dark"> Docker Hub API</button></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/hub/latest/ title="Docker Hub API">Docker Hub API</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/hub/deprecated/ title="Docker Hub API v1 (deprecated)">Docker Hub API v1 (deprecated)</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/hub/dvp/ title="DVP Data API">DVP Data API</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/api/extensions-sdk/>Extensions API</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/BackendV0/ title="Interface: BackendV0">Interface: BackendV0</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/DesktopUI/ title="Interface: DesktopUI">Interface: DesktopUI</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Dialog/ title="Interface: Dialog">Interface: Dialog</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Docker/ title="Interface: Docker">Interface: Docker</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/DockerCommand/ title="Interface: DockerCommand">Interface: DockerCommand</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/DockerDesktopClient/ title="Interface: DockerDesktopClient">Interface: DockerDesktopClient</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Exec/ title="Interface: Exec">Interface: Exec</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExecOptions/ title="Interface: ExecOptions">Interface: ExecOptions</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExecProcess/ title="Interface: ExecProcess">Interface: ExecProcess</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExecResult/ title="Interface: ExecResult">Interface: ExecResult</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExecResultV0/ title="Interface: ExecResultV0">Interface: ExecResultV0</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExecStreamOptions/ title="Interface: ExecStreamOptions">Interface: ExecStreamOptions</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Extension/ title="Interface: Extension">Interface: Extension</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExtensionCli/ title="Interface: ExtensionCli">Interface: ExtensionCli</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExtensionHost/ title="Interface: ExtensionHost">Interface: ExtensionHost</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ExtensionVM/ title="Interface: ExtensionVM">Interface: ExtensionVM</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Host/ title="Interface: Host">Interface: Host</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/HttpService/ title="Interface: HttpService">Interface: HttpService</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/NavigationIntents/ title="Interface: NavigationIntents">Interface: NavigationIntents</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/OpenDialogResult/ title="Interface: OpenDialogResult">Interface: OpenDialogResult</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/RawExecResult/ title="Interface: RawExecResult">Interface: RawExecResult</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/RequestConfig/ title="Interface: RequestConfig">Interface: RequestConfig</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/RequestConfigV0/ title="Interface: RequestConfigV0">Interface: RequestConfigV0</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/ServiceError/ title="Interface: ServiceError">Interface: ServiceError</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/SpawnOptions/ title="Interface: SpawnOptions">Interface: SpawnOptions</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/api/extensions-sdk/Toast/ title="Interface: Toast">Interface: Toast</a></li></ul></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/build-checks/>Build checks</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/consistent-instruction-casing/ title=ConsistentInstructionCasing>ConsistentInstructionCasing</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/copy-ignored-file/ title=CopyIgnoredFile>CopyIgnoredFile</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/duplicate-stage-name/ title=DuplicateStageName>DuplicateStageName</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/from-as-casing/ title=FromAsCasing>FromAsCasing</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/from-platform-flag-const-disallowed/ title=FromPlatformFlagConstDisallowed>FromPlatformFlagConstDisallowed</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/invalid-default-arg-in-from/ title=InvalidDefaultArgInFrom>InvalidDefaultArgInFrom</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/invalid-definition-description/ title=InvalidDefinitionDescription>InvalidDefinitionDescription</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/json-args-recommended/ title=JSONArgsRecommended>JSONArgsRecommended</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/legacy-key-value-format/ title=LegacyKeyValueFormat>LegacyKeyValueFormat</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/maintainer-deprecated/ title=MaintainerDeprecated>MaintainerDeprecated</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/multiple-instructions-disallowed/ title=MultipleInstructionsDisallowed>MultipleInstructionsDisallowed</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/no-empty-continuation/ title=NoEmptyContinuation>NoEmptyContinuation</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/redundant-target-platform/ title=RedundantTargetPlatform>RedundantTargetPlatform</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/reserved-stage-name/ title=ReservedStageName>ReservedStageName</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/secrets-used-in-arg-or-env/ title=SecretsUsedInArgOrEnv>SecretsUsedInArgOrEnv</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/stage-name-casing/ title=StageNameCasing>StageNameCasing</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/undefined-arg-in-from/ title=UndefinedArgInFrom>UndefinedArgInFrom</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/undefined-var/ title=UndefinedVar>UndefinedVar</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/build-checks/workdir-relative-path/ title=WorkdirRelativePath>WorkdirRelativePath</a></li></ul></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/compose-file/>Compose file reference</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/version-and-name/ title="Version and name top-level elements">Version and name top-level elements</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/services/ title="Services top-level elements">Services top-level elements</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/networks/ title="Networks top-level elements">Networks top-level elements</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/volumes/ title="Volumes top-level element">Volumes top-level element</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/configs/ title="Configs top-level elements">Configs top-level elements</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/secrets/ title="Secrets top-level elements">Secrets top-level elements</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/fragments/ title=Fragments>Fragments</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/extension/ title=Extensions>Extensions</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/interpolation/ title=Interpolation>Interpolation</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/merge/ title=Merge>Merge</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/include/ title=Include>Include</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/profiles/ title=Profiles>Profiles</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/build/ title="Compose Build Specification">Compose Build Specification</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/deploy/ title="Compose Deploy Specification">Compose Deploy Specification</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/develop/ title="Compose Develop Specification">Compose Develop Specification</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/compose-file/legacy-versions/ title="Legacy versions">Legacy versions</a></li></ul></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark bg-gray-light-200 dark:bg-gray-dark-200"><a aria-current=page id=sidebar-current-page class="py-2 w-full truncate block" href=https://docs.docker.com/reference/dockerfile/ title="Dockerfile reference">Dockerfile reference</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/glossary/ title=Glossary>Glossary</a></li><li x-data="{ expanded: false }"><div class="rounded px-4 w-full flex items-center justify-between"><div class="w-full py-2 truncate"><a class="block select-none hover:text-blue-light hover:dark:text-blue-dark" href=https://docs.docker.com/reference/samples/>Samples</a></div><button @click="expanded = !expanded" class="hover:bg-gray-light-300 hover:dark:bg-gray-dark-300 rounded"> <span :class="{ 'hidden' : expanded }" class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M464-376 306-533q-2-2-3.5-4.76-1.5-2.77-1.5-5.92.0-6.32 4.13-10.82 4.12-4.5 10.87-4.5h328q6.75.0 10.88 4.64 4.12 4.63 4.12 10.81.0 1.55-5 10.55L496-376q-3 3-7.06 5t-8.94 2q-4.87.0-8.94-2-4.06-2-7.06-5z"/></svg> </span><span :class="{ 'hidden' : !expanded }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M316-4e2q-6.75.0-10.87-4.64-4.13-4.63-4.13-10.81.0-1.55 5-10.55l158-157q3-3 7.06-5 4.07-2 8.94-2 4.88.0 8.94 2t7.06 5l158 157q2 2 3.5 4.76 1.5 2.77 1.5 5.92.0 6.32-4.12 10.82-4.13 4.5-10.88 4.5H316z"/></svg></span></button></div><ul :class="{ 'hidden' : !expanded }" class="hidden ml-3"><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/dotnet/ title=".NET samples">.NET samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/ai-ml/ title="AI/ML samples">AI/ML samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/angular/ title="Angular samples">Angular samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/cloudflared/ title="Cloudflared samples">Cloudflared samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/django/ title="Django samples">Django samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/elasticsearch/ title="Elasticsearch / Logstash / Kibana samples">Elasticsearch / Logstash / Kibana samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/express/ title="Express samples">Express samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/fastapi/ title="FastAPI samples">FastAPI samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/flask/ title="Flask samples">Flask samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/gitea/ title="Gitea samples">Gitea samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/go/ title="Go samples">Go samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/java/ title="Java samples">Java samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/javascript/ title="JavaScript samples">JavaScript samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/mariadb/ title="MariaDB samples">MariaDB samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/minecraft/ title="Minecraft samples">Minecraft samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/mongodb/ title="MongoDB samples">MongoDB samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/ms-sql/ title="MS-SQL samples">MS-SQL samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/mysql/ title="MySQL samples">MySQL samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/nextcloud/ title="Nextcloud samples">Nextcloud samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/nginx/ title="NGINX samples">NGINX samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/nodejs/ title="Node.js samples">Node.js samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/php/ title="PHP samples">PHP samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/pi-hole/ title="Pi-hole samples">Pi-hole samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/plex/ title="Plex samples">Plex samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/portainer/ title="Portainer samples">Portainer samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/postgres/ title="PostgreSQL samples">PostgreSQL samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/prometheus/ title="Prometheus samples">Prometheus samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/python/ title="Python samples">Python samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/rails/ title="Rails samples">Rails samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/react/ title="React samples">React samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/redis/ title="Redis samples">Redis samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/ruby/ title="Ruby samples">Ruby samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/rust/ title="Rust samples">Rust samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/spark/ title="Spark samples">Spark samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/spring/ title="Spring Boot samples">Spring Boot samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/traefik/ title="Traefik samples">Traefik samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/typescript/ title="TypeScript samples">TypeScript samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/vuejs/ title="Vue.js samples">Vue.js samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/wireguard/ title="WireGuard samples">WireGuard samples</a></li><li class="rounded px-4 hover:text-blue-light hover:dark:text-blue-dark"><a class="py-2 w-full truncate block" href=https://docs.docker.com/reference/samples/wordpress/ title="WordPress samples">WordPress samples</a></li></ul></li></ul></nav></div></div><div data-pagefind-body class="w-full min-w-0 bg-white p-8 dark:bg-background-dark"><div class="flex gap-8 w-full"><article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert"><nav id=breadcrumbs data-pagefind-ignore class="gap-4 flex items-center text-gray-light dark:text-gray-dark min-w-0"><a href=https://docs.docker.com/ class="link truncate">Home</a> <span>/</span> <a href=https://docs.docker.com/reference/ class="link truncate">Reference</a> <span>/</span> <span data-pagefind-meta="breadcrumbs:Home / Reference" class=truncate>Dockerfile reference</span></nav><h1 data-pagefind-weight=10 class=scroll-mt-36>Dockerfile reference</h1><div class="block lg:hidden"><div data-pagefind-ignore class=not-prose><div class="text-lg pb-0 lg:pb-2">Table of contents</div><nav class=toc><ul class=pl-2><li><a class="link lg:no-underline" href=#overview>Overview</a></li><li><a class="link lg:no-underline" href=#format>Format</a></li><li><a class="link lg:no-underline" href=#parser-directives>Parser directives</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#syntax>syntax</a></li><li><a class="link lg:no-underline" href=#escape>escape</a></li><li><a class="link lg:no-underline" href=#check>check</a></li></ul><li><a class="link lg:no-underline" href=#environment-replacement>Environment replacement</a></li><li><a class="link lg:no-underline" href=#dockerignore-file>.dockerignore file</a></li><li><a class="link lg:no-underline" href=#shell-and-exec-form>Shell and exec form</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#exec-form>Exec form</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#shell-form>Shell form</a></li><li><a class="link lg:no-underline" href=#use-a-different-shell>Use a different shell</a></li></ul><li><a class="link lg:no-underline" href=#from>FROM</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#understand-how-arg-and-from-interact>Understand how ARG and FROM interact</a></li></ul><li><a class="link lg:no-underline" href=#run>RUN</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#cache-invalidation-for-run-instructions>Cache invalidation for RUN instructions</a></li><li><a class="link lg:no-underline" href=#run---mount>RUN --mount</a></li><li><a class="link lg:no-underline" href=#run---mounttypebind>RUN --mount=type=bind</a></li><li><a class="link lg:no-underline" href=#run---mounttypecache>RUN --mount=type=cache</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---mounttypetmpfs>RUN --mount=type=tmpfs</a></li><li><a class="link lg:no-underline" href=#run---mounttypesecret>RUN --mount=type=secret</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---mounttypessh>RUN --mount=type=ssh</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---network>RUN --network</a></li><li><a class="link lg:no-underline" href=#run---networkdefault>RUN --network=default</a></li><li><a class="link lg:no-underline" href=#run---networknone>RUN --network=none</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---networkhost>RUN --network=host</a></li><li><a class="link lg:no-underline" href=#run---security>RUN --security</a></li><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#cmd>CMD</a></li><li><a class="link lg:no-underline" href=#label>LABEL</a></li><li><a class="link lg:no-underline" href=#maintainer-deprecated>MAINTAINER (deprecated)</a></li><li><a class="link lg:no-underline" href=#expose>EXPOSE</a></li><li><a class="link lg:no-underline" href=#env>ENV</a></li><li><a class="link lg:no-underline" href=#add>ADD</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#source>Source</a></li><ul class=pl-2><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#destination>Destination</a></li><li><a class="link lg:no-underline" href=#add---keep-git-dir>ADD --keep-git-dir</a></li><li><a class="link lg:no-underline" href=#add---checksum>ADD --checksum</a></li><li><a class="link lg:no-underline" href=#add---chown---chmod>ADD --chown --chmod</a></li><li><a class="link lg:no-underline" href=#add---link>ADD --link</a></li><li><a class="link lg:no-underline" href=#add---exclude>ADD --exclude</a></li></ul><li><a class="link lg:no-underline" href=#copy>COPY</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#source-1>Source</a></li><ul class=pl-2><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#destination-1>Destination</a></li><li><a class="link lg:no-underline" href=#copy---from>COPY --from</a></li><li><a class="link lg:no-underline" href=#copy---chown---chmod>COPY --chown --chmod</a></li><li><a class="link lg:no-underline" href=#copy---link>COPY --link</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#copy---parents>COPY --parents</a></li><li><a class="link lg:no-underline" href=#copy---exclude>COPY --exclude</a></li></ul><li><a class="link lg:no-underline" href=#entrypoint>ENTRYPOINT</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#exec-form-entrypoint-example>Exec form ENTRYPOINT example</a></li><li><a class="link lg:no-underline" href=#shell-form-entrypoint-example>Shell form ENTRYPOINT example</a></li><li><a class="link lg:no-underline" href=#understand-how-cmd-and-entrypoint-interact>Understand how CMD and ENTRYPOINT interact</a></li></ul><li><a class="link lg:no-underline" href=#volume>VOLUME</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#notes-about-specifying-volumes>Notes about specifying volumes</a></li></ul><li><a class="link lg:no-underline" href=#user>USER</a></li><li><a class="link lg:no-underline" href=#workdir>WORKDIR</a></li><li><a class="link lg:no-underline" href=#arg>ARG</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#default-values>Default values</a></li><li><a class="link lg:no-underline" href=#scope>Scope</a></li><li><a class="link lg:no-underline" href=#using-arg-variables>Using ARG variables</a></li><li><a class="link lg:no-underline" href=#predefined-args>Predefined ARGs</a></li><li><a class="link lg:no-underline" href=#automatic-platform-args-in-the-global-scope>Automatic platform ARGs in the global scope</a></li><li><a class="link lg:no-underline" href=#buildkit-built-in-build-args>BuildKit built-in build args</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#impact-on-build-caching>Impact on build caching</a></li></ul><li><a class="link lg:no-underline" href=#onbuild>ONBUILD</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#copy-or-mount-from-stage-image-or-context>Copy or mount from stage, image, or context</a></li><li><a class="link lg:no-underline" href=#onbuild-limitations>ONBUILD limitations</a></li></ul><li><a class="link lg:no-underline" href=#stopsignal>STOPSIGNAL</a></li><li><a class="link lg:no-underline" href=#healthcheck>HEALTHCHECK</a></li><li><a class="link lg:no-underline" href=#shell>SHELL</a></li><li><a class="link lg:no-underline" href=#here-documents>Here-Documents</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#example-running-a-multi-line-script>Example: Running a multi-line script</a></li><li><a class="link lg:no-underline" href=#example-creating-inline-files>Example: Creating inline files</a></li></ul><li><a class="link lg:no-underline" href=#dockerfile-examples>Dockerfile examples</a></li></ul></nav></div><hr></div><p>Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. This page describes the commands you can use in a Dockerfile.</p><h2 class=scroll-mt-20 id=overview><a class="text-black dark:text-white no-underline hover:underline" href=#overview>Overview</a></h2><p>The Dockerfile supports the following instructions:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2 style=text-align:left>Instruction</th><th class=p-2 style=text-align:left>Description</th></tr></thead><tbody><tr><td class=p-2 style=text-align:left><a class=link href=#add><code>ADD</code></a></td><td class=p-2 style=text-align:left>Add local or remote files and directories.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#arg><code>ARG</code></a></td><td class=p-2 style=text-align:left>Use build-time variables.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#cmd><code>CMD</code></a></td><td class=p-2 style=text-align:left>Specify default commands.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#copy><code>COPY</code></a></td><td class=p-2 style=text-align:left>Copy files and directories.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#entrypoint><code>ENTRYPOINT</code></a></td><td class=p-2 style=text-align:left>Specify default executable.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#env><code>ENV</code></a></td><td class=p-2 style=text-align:left>Set environment variables.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#expose><code>EXPOSE</code></a></td><td class=p-2 style=text-align:left>Describe which ports your application is listening on.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#from><code>FROM</code></a></td><td class=p-2 style=text-align:left>Create a new build stage from a base image.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#healthcheck><code>HEALTHCHECK</code></a></td><td class=p-2 style=text-align:left>Check a container's health on startup.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#label><code>LABEL</code></a></td><td class=p-2 style=text-align:left>Add metadata to an image.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#maintainer-deprecated><code>MAINTAINER</code></a></td><td class=p-2 style=text-align:left>Specify the author of an image.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#onbuild><code>ONBUILD</code></a></td><td class=p-2 style=text-align:left>Specify instructions for when the image is used in a build.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#run><code>RUN</code></a></td><td class=p-2 style=text-align:left>Execute build commands.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#shell><code>SHELL</code></a></td><td class=p-2 style=text-align:left>Set the default shell of an image.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#stopsignal><code>STOPSIGNAL</code></a></td><td class=p-2 style=text-align:left>Specify the system call signal for exiting a container.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#user><code>USER</code></a></td><td class=p-2 style=text-align:left>Set user and group ID.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#volume><code>VOLUME</code></a></td><td class=p-2 style=text-align:left>Create volume mounts.</td></tr><tr><td class=p-2 style=text-align:left><a class=link href=#workdir><code>WORKDIR</code></a></td><td class=p-2 style=text-align:left>Change working directory.</td></tr></tbody></table></div><h2 class=scroll-mt-20 id=format><a class="text-black dark:text-white no-underline hover:underline" href=#format>Format</a></h2><p>Here is the format of the Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBDb21tZW50CklOU1RSVUNUSU9OIGFyZ3VtZW50cw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># Comment</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>INSTRUCTION arguments</span></span></code></pre></div></div></div></div><p>The instruction is not case-sensitive. However, convention is for them to be UPPERCASE to distinguish them from arguments more easily.</p><p>Docker runs instructions in a Dockerfile in order. A Dockerfile <strong>must begin with a <code>FROM</code> instruction</strong>. This may be after <a class=link href=#parser-directives>parser directives</a>, <a class=link href=#format>comments</a>, and globally scoped <a class=link href=#arg>ARGs</a>. The <code>FROM</code> instruction specifies the <a class=link href=https://docs.docker.com/glossary/#base-image rel=noopener>base image<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> from which you are building. <code>FROM</code> may only be preceded by one or more <code>ARG</code> instructions, which declare arguments that are used in <code>FROM</code> lines in the Dockerfile.</p><p>BuildKit treats lines that begin with <code>#</code> as a comment, unless the line is a valid <a class=link href=#parser-directives>parser directive</a>. A <code>#</code> marker anywhere else in a line is treated as an argument. This allows statements like:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBDb21tZW50ClJVTiBlY2hvICd3ZSBhcmUgcnVubmluZyBzb21lICMgb2YgY29vbCB0aGluZ3Mn', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># Comment</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s1>'we are running some # of cool things'</span></span></span></code></pre></div></div></div></div><p>Comment lines are removed before the Dockerfile instructions are executed. The comment in the following example is removed before the shell executes the <code>echo</code> command.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gaGVsbG8gXAojIGNvbW1lbnQKd29ybGQ=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> hello <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span><span class=c1># comment</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>world</span></span></code></pre></div></div></div></div><p>The following examples is equivalent.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gaGVsbG8gXAp3b3JsZA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> hello <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span>world</span></span></code></pre></div></div></div></div><p>Comments don't support line continuation characters.</p><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p><strong>Note on whitespace</strong></p><p>For backward compatibility, leading whitespace before comments (<code>#</code>) and instructions (such as <code>RUN</code>) are ignored, but discouraged. Leading whitespace is not preserved in these cases, and the following examples are therefore equivalent:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'ICAgICAgICAjIHRoaXMgaXMgYSBjb21tZW50LWxpbmUKICAgIFJVTiBlY2hvIGhlbGxvClJVTiBlY2hvIHdvcmxk', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl> <span class=c1># this is a comment-line</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> RUN <span class=nb>echo</span> hello<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> world</span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyB0aGlzIGlzIGEgY29tbWVudC1saW5lClJVTiBlY2hvIGhlbGxvClJVTiBlY2hvIHdvcmxk', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># this is a comment-line</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> world</span></span></code></pre></div></div></div></div><p>Whitespace in instruction arguments, however, isn't ignored. The following example prints <code>hello world</code> with leading whitespace as specified:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gIlwKICAgICBoZWxsb1wKICAgICB3b3JsZCI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>"\ </span></span></span><span class=line><span class=cl><span class=s2> hello\ </span></span></span><span class=line><span class=cl><span class=s2> world"</span></span></span></code></pre></div></div></div></div></blockquote><h2 class=scroll-mt-20 id=parser-directives><a class="text-black dark:text-white no-underline hover:underline" href=#parser-directives>Parser directives</a></h2><p>Parser directives are optional, and affect the way in which subsequent lines in a Dockerfile are handled. Parser directives don't add layers to the build, and don't show up as build steps. Parser directives are written as a special type of comment in the form <code># directive=value</code>. A single directive may only be used once.</p><p>The following parser directives are supported:</p><ul><li><a class=link href=#syntax><code>syntax</code></a></li><li><a class=link href=#escape><code>escape</code></a></li><li><a class=link href=#check><code>check</code></a> (since Dockerfile v1.8.0)</li></ul><p>Once a comment, empty line or builder instruction has been processed, BuildKit no longer looks for parser directives. Instead it treats anything formatted as a parser directive as a comment and doesn't attempt to validate if it might be a parser directive. Therefore, all parser directives must be at the top of a Dockerfile.</p><p>Parser directive keys, such as <code>syntax</code> or <code>check</code>, aren't case-sensitive, but they're lowercase by convention. Values for a directive are case-sensitive and must be written in the appropriate case for the directive. For example, <code>#check=skip=jsonargsrecommended</code> is invalid because the check name must use Pascal case, not lowercase. It's also conventional to include a blank line following any parser directives. Line continuation characters aren't supported in parser directives.</p><p>Due to these rules, the following examples are all invalid:</p><p>Invalid due to line continuation:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBkaXJlYyBcCnRpdmU9dmFsdWU=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># direc \</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=nv>tive</span><span class=o>=</span>value</span></span></code></pre></div></div></div></div><p>Invalid due to appearing twice:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBkaXJlY3RpdmU9dmFsdWUxCiMgZGlyZWN0aXZlPXZhbHVlMgoKRlJPTSBJbWFnZU5hbWU=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># directive=value1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value2</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ImageName</span></span></span></code></pre></div></div></div></div><p>Treated as a comment because it appears after a builder instruction:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBJbWFnZU5hbWUKIyBkaXJlY3RpdmU9dmFsdWU=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ImageName</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value</span></span></span></code></pre></div></div></div></div><p>Treated as a comment because it appears after a comment that isn't a parser directive:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBBYm91dCBteSBkb2NrZXJmaWxlCiMgZGlyZWN0aXZlPXZhbHVlCkZST00gSW1hZ2VOYW1l', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># About my dockerfile</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ImageName</span></span></span></code></pre></div></div></div></div><p>The following <code>unknowndirective</code> is treated as a comment because it isn't recognized. The known <code>syntax</code> directive is treated as a comment because it appears after a comment that isn't a parser directive.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyB1bmtub3duZGlyZWN0aXZlPXZhbHVlCiMgc3ludGF4PXZhbHVl', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># unknowndirective=value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># syntax=value</span></span></span></code></pre></div></div></div></div><p>Non line-breaking whitespace is permitted in a parser directive. Hence, the following lines are all treated identically:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'I2RpcmVjdGl2ZT12YWx1ZQojIGRpcmVjdGl2ZSA9dmFsdWUKIwlkaXJlY3RpdmU9IHZhbHVlCiMgZGlyZWN0aXZlID0gdmFsdWUKIwkgIGRJckVjVGlWZT12YWx1ZQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c>#directive=value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive =value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive= value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive = value</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># dIrEcTiVe=value</span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=syntax><a class="text-black dark:text-white no-underline hover:underline" href=#syntax>syntax</a></h3><p><a name=external-implementation-features></a></p><p>Use the <code>syntax</code> parser directive to declare the Dockerfile syntax version to use for the build. If unspecified, BuildKit uses a bundled version of the Dockerfile frontend. Declaring a syntax version lets you automatically use the latest Dockerfile version without having to upgrade BuildKit or Docker Engine, or even use a custom Dockerfile implementation.</p><p>Most users will want to set this parser directive to <code>docker/dockerfile:1</code>, which causes BuildKit to pull the latest stable version of the Dockerfile syntax before the build.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span></span></span></code></pre></div></div></div></div><p>For more information about how the parser directive works, see <a class=link href=https://docs.docker.com/build/buildkit/dockerfile-frontend/ rel=noopener>Custom Dockerfile syntax<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=escape><a class="text-black dark:text-white no-underline hover:underline" href=#escape>escape</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9XA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=\</span></span></span></code></pre></div></div></div></div><p>Or</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span></span></span></code></pre></div></div></div></div><p>The <code>escape</code> directive sets the character used to escape characters in a Dockerfile. If not specified, the default escape character is <code>\</code>.</p><p>The escape character is used both to escape characters in a line, and to escape a newline. This allows a Dockerfile instruction to span multiple lines. Note that regardless of whether the <code>escape</code> parser directive is included in a Dockerfile, escaping is not performed in a <code>RUN</code> command, except at the end of a line.</p><p>Setting the escape character to <code>`</code> is especially useful on <code>Windows</code>, where <code>\</code> is the directory path separator. <code>`</code> is consistent with <a class=link href=https://technet.microsoft.com/en-us/library/hh847755.aspx rel=noopener>Windows PowerShell<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><p>Consider the following example which would fail in a non-obvious way on Windows. The second <code>\</code> at the end of the second line would be interpreted as an escape for the newline, instead of a target of the escape from the first <code>\</code>. Similarly, the <code>\</code> at the end of the third line would, assuming it was actually handled as an instruction, cause it be treated as a line continuation. The result of this Dockerfile is that second and third lines are considered a single instruction:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpDT1BZIHRlc3RmaWxlLnR4dCBjOlxcClJVTiBkaXIgYzpc', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> testfile.txt c:<span class=se>\\</span> </span></span><span class=line><span class=cl>RUN dir c:<span class=err>\</span></span></span></code></pre></div></div></div></div><p>Results in:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgY21kIC4KClNlbmRpbmcgYnVpbGQgY29udGV4dCB0byBEb2NrZXIgZGFlbW9uIDMuMDcyIGtCClN0ZXAgMS8yIDogRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgogLS0tPiAyMjczOGZmNDljNmQKU3RlcCAyLzIgOiBDT1BZIHRlc3RmaWxlLnR4dCBjOlxSVU4gZGlyIGM6CkdldEZpbGVBdHRyaWJ1dGVzRXggYzpSVU46IFRoZSBzeXN0ZW0gY2Fubm90IGZpbmQgdGhlIGZpbGUgc3BlY2lmaWVkLgpQUyBFOlxteXByb2plY3Q+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject> docker build -t cmd . </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 3.072 kB </span></span></span><span class=line><span class=cl><span class=go>Step 1/2 : FROM microsoft/nanoserver </span></span></span><span class=line><span class=cl><span class=go> ---> 22738ff49c6d </span></span></span><span class=line><span class=cl><span class=go>Step 2/2 : COPY testfile.txt c:\RUN dir c: </span></span></span><span class=line><span class=cl><span class=go>GetFileAttributesEx c:RUN: The system cannot find the file specified. </span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject> </span></span></span></code></pre></div></div></div></div><p>One solution to the above would be to use <code>/</code> as the target of both the <code>COPY</code> instruction, and <code>dir</code>. However, this syntax is, at best, confusing as it is not natural for paths on Windows, and at worst, error prone as not all commands on Windows support <code>/</code> as the path separator.</p><p>By adding the <code>escape</code> parser directive, the following Dockerfile succeeds as expected with the use of natural platform semantics for file paths on Windows:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YAoKRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpDT1BZIHRlc3RmaWxlLnR4dCBjOlwKUlVOIGRpciBjOlw=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> testfile.txt c:<span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span>RUN dir c:<span class=err>\</span></span></span></code></pre></div></div></div></div><p>Results in:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgc3VjY2VlZHMgLS1uby1jYWNoZT10cnVlIC4KClNlbmRpbmcgYnVpbGQgY29udGV4dCB0byBEb2NrZXIgZGFlbW9uIDMuMDcyIGtCClN0ZXAgMS8zIDogRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgogLS0tPiAyMjczOGZmNDljNmQKU3RlcCAyLzMgOiBDT1BZIHRlc3RmaWxlLnR4dCBjOlwKIC0tLT4gOTY2NTVkZTMzOGRlClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgNGRiOWFjYmIxNjgyClN0ZXAgMy8zIDogUlVOIGRpciBjOlwKIC0tLT4gUnVubmluZyBpbiBhMmMxNTdmODQyZjUKIFZvbHVtZSBpbiBkcml2ZSBDIGhhcyBubyBsYWJlbC4KIFZvbHVtZSBTZXJpYWwgTnVtYmVyIGlzIDdFNkQtRTBGNwoKIERpcmVjdG9yeSBvZiBjOlwKCjEwLzA1LzIwMTYgIDA1OjA0IFBNICAgICAgICAgICAgIDEsODk0IExpY2Vuc2UudHh0CjEwLzA1LzIwMTYgIDAyOjIyIFBNICAgIDxESVI+ICAgICAgICAgIFByb2dyYW0gRmlsZXMKMTAvMDUvMjAxNiAgMDI6MTQgUE0gICAgPERJUj4gICAgICAgICAgUHJvZ3JhbSBGaWxlcyAoeDg2KQoxMC8yOC8yMDE2ICAxMToxOCBBTSAgICAgICAgICAgICAgICA2MiB0ZXN0ZmlsZS50eHQKMTAvMjgvMjAxNiAgMTE6MjAgQU0gICAgPERJUj4gICAgICAgICAgVXNlcnMKMTAvMjgvMjAxNiAgMTE6MjAgQU0gICAgPERJUj4gICAgICAgICAgV2luZG93cwogICAgICAgICAgIDIgRmlsZShzKSAgICAgICAgICAxLDk1NiBieXRlcwogICAgICAgICAgIDQgRGlyKHMpICAyMSwyNTksMDk2LDA2NCBieXRlcyBmcmVlCiAtLS0+IDAxYzdmM2JlZjA0ZgpSZW1vdmluZyBpbnRlcm1lZGlhdGUgY29udGFpbmVyIGEyYzE1N2Y4NDJmNQpTdWNjZXNzZnVsbHkgYnVpbHQgMDFjN2YzYmVmMDRmClBTIEU6XG15cHJvamVjdD4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject> docker build -t succeeds --no-cache=true . </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 3.072 kB </span></span></span><span class=line><span class=cl><span class=go>Step 1/3 : FROM microsoft/nanoserver </span></span></span><span class=line><span class=cl><span class=go> ---> 22738ff49c6d </span></span></span><span class=line><span class=cl><span class=go>Step 2/3 : COPY testfile.txt c:\ </span></span></span><span class=line><span class=cl><span class=go> ---> 96655de338de </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container 4db9acbb1682 </span></span></span><span class=line><span class=cl><span class=go>Step 3/3 : RUN dir c:\ </span></span></span><span class=line><span class=cl><span class=go> ---> Running in a2c157f842f5 </span></span></span><span class=line><span class=cl><span class=go> Volume in drive C has no label. </span></span></span><span class=line><span class=cl><span class=go> Volume Serial Number is 7E6D-E0F7 </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go> Directory of c:\ </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>10/05/2016 05:04 PM 1,894 License.txt </span></span></span><span class=line><span class=cl><span class=go>10/05/2016 02:22 PM <DIR> Program Files </span></span></span><span class=line><span class=cl><span class=go>10/05/2016 02:14 PM <DIR> Program Files (x86) </span></span></span><span class=line><span class=cl><span class=go>10/28/2016 11:18 AM 62 testfile.txt </span></span></span><span class=line><span class=cl><span class=go>10/28/2016 11:20 AM <DIR> Users </span></span></span><span class=line><span class=cl><span class=go>10/28/2016 11:20 AM <DIR> Windows </span></span></span><span class=line><span class=cl><span class=go> 2 File(s) 1,956 bytes </span></span></span><span class=line><span class=cl><span class=go> 4 Dir(s) 21,259,096,064 bytes free </span></span></span><span class=line><span class=cl><span class=go> ---> 01c7f3bef04f </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container a2c157f842f5 </span></span></span><span class=line><span class=cl><span class=go>Successfully built 01c7f3bef04f </span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject> </span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=check><a class="text-black dark:text-white no-underline hover:underline" href=#check>check</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjaGVjaz1za2lwPTxjaGVja3N8YWxsPgojIGNoZWNrPWVycm9yPTxib29sZWFuPg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># check=skip=<checks|all></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># check=error=<boolean></span></span></span></code></pre></div></div></div></div><p>The <code>check</code> directive is used to configure how <a class=link href=https://docs.docker.com/build/checks/ rel=noopener>build checks<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> are evaluated. By default, all checks are run, and failures are treated as warnings.</p><p>You can disable specific checks using <code>#check=skip=<check-name></code>. To specify multiple checks to skip, separate them with a comma:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjaGVjaz1za2lwPUpTT05BcmdzUmVjb21tZW5kZWQsU3RhZ2VOYW1lQ2FzaW5n', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># check=skip=JSONArgsRecommended,StageNameCasing</span></span></span></code></pre></div></div></div></div><p>To disable all checks, use <code>#check=skip=all</code>.</p><p>By default, builds with failing build checks exit with a zero status code despite warnings. To make the build fail on warnings, set <code>#check=error=true</code>.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjaGVjaz1lcnJvcj10cnVl', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># check=error=true</span></span></span></code></pre></div></div></div></div><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>When using the <code>check</code> directive, with <code>error=true</code> option, it is recommended to pin the <a class=link href=#syntax>Dockerfile syntax</a> to a specific version. Otherwise, your build may start to fail when new checks are added in the future versions.</p></blockquote><p>To combine both the <code>skip</code> and <code>error</code> options, use a semi-colon to separate them:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjaGVjaz1za2lwPUpTT05BcmdzUmVjb21tZW5kZWQ7ZXJyb3I9dHJ1ZQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># check=skip=JSONArgsRecommended;error=true</span></span></span></code></pre></div></div></div></div><p>To see all available checks, see the <a class=link href=https://docs.docker.com/reference/build-checks/ rel=noopener>build checks reference<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>. Note that the checks available depend on the Dockerfile syntax version. To make sure you're getting the most up-to-date checks, use the <a class=link href=#syntax><code>syntax</code></a> directive to specify the Dockerfile syntax version to the latest stable version.</p><h2 class=scroll-mt-20 id=environment-replacement><a class="text-black dark:text-white no-underline hover:underline" href=#environment-replacement>Environment replacement</a></h2><p>Environment variables (declared with <a class=link href=#env>the <code>ENV</code> statement</a>) can also be used in certain instructions as variables to be interpreted by the Dockerfile. Escapes are also handled for including variable-like syntax into a statement literally.</p><p>Environment variables are notated in the Dockerfile either with <code>$variable_name</code> or <code>${variable_name}</code>. They are treated equivalently and the brace syntax is typically used to address issues with variable names with no whitespace, like <code>${foo}_bar</code>.</p><p>The <code>${variable_name}</code> syntax also supports a few of the standard <code>bash</code> modifiers as specified below:</p><ul><li><code>${variable:-word}</code> indicates that if <code>variable</code> is set then the result will be that value. If <code>variable</code> is not set then <code>word</code> will be the result.</li><li><code>${variable:+word}</code> indicates that if <code>variable</code> is set then <code>word</code> will be the result, otherwise the result is the empty string.</li></ul><p>The following variable replacements are supported in a pre-release version of Dockerfile syntax, when using the <code># syntax=docker/dockerfile-upstream:master</code> syntax directive in your Dockerfile:</p><ul><li><p><code>${variable#pattern}</code> removes the shortest match of <code>pattern</code> from <code>variable</code>, seeking from the start of the string.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyPWZvb2JhcmJheiBlY2hvICR7c3RyI2YqYn0gICAgICMgYXJiYXo=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>str</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>str</span><span class=p>#f*b</span><span class=si>}</span> <span class=c1># arbaz</span></span></span></code></pre></div></div></div></div></li><li><p><code>${variable##pattern}</code> removes the longest match of <code>pattern</code> from <code>variable</code>, seeking from the start of the string.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyPWZvb2JhcmJheiBlY2hvICR7c3RyIyNmKmJ9ICAgICMgYXo=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>str</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>str</span><span class=p>##f*b</span><span class=si>}</span> <span class=c1># az</span></span></span></code></pre></div></div></div></div></li><li><p><code>${variable%pattern}</code> removes the shortest match of <code>pattern</code> from <code>variable</code>, seeking backwards from the end of the string.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nJWIqfSAgICAjIGZvb2Jhcg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>%b*</span><span class=si>}</span> <span class=c1># foobar</span></span></span></code></pre></div></div></div></div></li><li><p><code>${variable%%pattern}</code> removes the longest match of <code>pattern</code> from <code>variable</code>, seeking backwards from the end of the string.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nJSViKn0gICAjIGZvbw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>%%b*</span><span class=si>}</span> <span class=c1># foo</span></span></span></code></pre></div></div></div></div></li><li><p><code>${variable/pattern/replacement}</code> replace the first occurrence of <code>pattern</code> in <code>variable</code> with <code>replacement</code></p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nL2JhL2ZvfSAgIyBmb29mb3JiYXo=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>/ba/fo</span><span class=si>}</span> <span class=c1># fooforbaz</span></span></span></code></pre></div></div></div></div></li><li><p><code>${variable//pattern/replacement}</code> replaces all occurrences of <code>pattern</code> in <code>variable</code> with <code>replacement</code></p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nLy9iYS9mb30gICMgZm9vZm9yZm96', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>//ba/fo</span><span class=si>}</span> <span class=c1># fooforfoz</span></span></span></code></pre></div></div></div></div></li></ul><p>In all cases, <code>word</code> can be any string, including additional environment variables.</p><p><code>pattern</code> is a glob pattern where <code>?</code> matches any single character and <code>*</code> any number of characters (including zero). To match literal <code>?</code> and <code>*</code>, use a backslash escape: <code>\?</code> and <code>\*</code>.</p><p>You can escape whole variable names by adding a <code>\</code> before the variable: <code>\$foo</code> or <code>\${foo}</code>, for example, will translate to <code>$foo</code> and <code>${foo}</code> literals respectively.</p><p>Example (parsed representation is displayed after the <code>#</code>):</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkVOViBGT089L2JhcgpXT1JLRElSICR7Rk9PfSAgICMgV09SS0RJUiAvYmFyCkFERCAuICRGT08gICAgICAgIyBBREQgLiAvYmFyCkNPUFkgXCRGT08gL3F1dXggIyBDT1BZICRGT08gL3F1dXg=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>FOO</span><span class=o>=</span>/bar<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> ${FOO} # WORKDIR /bar</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> . <span class=nv>$FOO</span> <span class=c1># ADD . /bar</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> <span class=se>\$</span>FOO /quux <span class=c1># COPY $FOO /quux</span></span></span></code></pre></div></div></div></div><p>Environment variables are supported by the following list of instructions in the Dockerfile:</p><ul><li><code>ADD</code></li><li><code>COPY</code></li><li><code>ENV</code></li><li><code>EXPOSE</code></li><li><code>FROM</code></li><li><code>LABEL</code></li><li><code>STOPSIGNAL</code></li><li><code>USER</code></li><li><code>VOLUME</code></li><li><code>WORKDIR</code></li><li><code>ONBUILD</code> (when combined with one of the supported instructions above)</li></ul><p>You can also use environment variables with <code>RUN</code>, <code>CMD</code>, and <code>ENTRYPOINT</code> instructions, but in those cases the variable substitution is handled by the command shell, not the builder. Note that instructions using the exec form don't invoke a command shell automatically. See <a class=link href=#variable-substitution>Variable substitution</a>.</p><p>Environment variable substitution use the same value for each variable throughout the entire instruction. Changing the value of a variable only takes effect in subsequent instructions. Consider the following example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIGFiYz1oZWxsbwpFTlYgYWJjPWJ5ZSBkZWY9JGFiYwpFTlYgZ2hpPSRhYmM=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>abc</span><span class=o>=</span>hello </span></span><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>abc</span><span class=o>=</span>bye <span class=nv>def</span><span class=o>=</span><span class=nv>$abc</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>ghi</span><span class=o>=</span><span class=nv>$abc</span></span></span></code></pre></div></div></div></div><ul><li>The value of <code>def</code> becomes <code>hello</code></li><li>The value of <code>ghi</code> becomes <code>bye</code></li></ul><h2 class=scroll-mt-20 id=dockerignore-file><a class="text-black dark:text-white no-underline hover:underline" href=#dockerignore-file>.dockerignore file</a></h2><p>You can use <code>.dockerignore</code> file to exclude files and directories from the build context. For more information, see <a class=link href=https://docs.docker.com/build/building/context/#dockerignore-files rel=noopener>.dockerignore file<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h2 class=scroll-mt-20 id=shell-and-exec-form><a class="text-black dark:text-white no-underline hover:underline" href=#shell-and-exec-form>Shell and exec form</a></h2><p>The <code>RUN</code>, <code>CMD</code>, and <code>ENTRYPOINT</code> instructions all have two possible forms:</p><ul><li><code>INSTRUCTION ["executable","param1","param2"]</code> (exec form)</li><li><code>INSTRUCTION command param1 param2</code> (shell form)</li></ul><p>The exec form makes it possible to avoid shell string munging, and to invoke commands using a specific command shell, or any other executable. It uses a JSON array syntax, where each element in the array is a command, flag, or argument.</p><p>The shell form is more relaxed, and emphasizes ease of use, flexibility, and readability. The shell form automatically uses a command shell, whereas the exec form does not.</p><h3 class=scroll-mt-20 id=exec-form><a class="text-black dark:text-white no-underline hover:underline" href=#exec-form>Exec form</a></h3><p>The exec form is parsed as a JSON array, which means that you must use double-quotes (") around words, not single-quotes (').</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBbIi9iaW4vYmFzaCIsICItYyIsICJlY2hvIGhlbGxvIl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>"/bin/bash"</span><span class=p>,</span> <span class=s2>"-c"</span><span class=p>,</span> <span class=s2>"echo hello"</span><span class=p>]</span></span></span></code></pre></div></div></div></div><p>The exec form is best used to specify an <code>ENTRYPOINT</code> instruction, combined with <code>CMD</code> for setting default arguments that can be overridden at runtime. For more information, see <a class=link href=#entrypoint>ENTRYPOINT</a>.</p><h4 class=scroll-mt-20 id=variable-substitution><a class="text-black dark:text-white no-underline hover:underline" href=#variable-substitution>Variable substitution</a></h4><p>Using the exec form doesn't automatically invoke a command shell. This means that normal shell processing, such as variable substitution, doesn't happen. For example, <code>RUN [ "echo", "$HOME" ]</code> won't handle variable substitution for <code>$HOME</code>.</p><p>If you want shell processing then either use the shell form or execute a shell directly with the exec form, for example: <code>RUN [ "sh", "-c", "echo $HOME" ]</code>. When using the exec form and executing a shell directly, as in the case for the shell form, it's the shell that's doing the environment variable substitution, not the builder.</p><h4 class=scroll-mt-20 id=backslashes><a class="text-black dark:text-white no-underline hover:underline" href=#backslashes>Backslashes</a></h4><p>In exec form, you must escape backslashes. This is particularly relevant on Windows where the backslash is the path separator. The following line would otherwise be treated as shell form due to not being valid JSON, and fail in an unexpected way:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIFsiYzpcd2luZG93c1xzeXN0ZW0zMlx0YXNrbGlzdC5leGUiXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>"c:\windows\system32\tasklist.exe"</span><span class=o>]</span></span></span></code></pre></div></div></div></div><p>The correct syntax for this example is:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIFsiYzpcXHdpbmRvd3NcXHN5c3RlbTMyXFx0YXNrbGlzdC5leGUiXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>"c:\\windows\\system32\\tasklist.exe"</span><span class=o>]</span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=shell-form><a class="text-black dark:text-white no-underline hover:underline" href=#shell-form>Shell form</a></h3><p>Unlike the exec form, instructions using the shell form always use a command shell. The shell form doesn't use the JSON array format, instead it's a regular string. The shell form string lets you escape newlines using the <a class=link href=#escape>escape character</a> (backslash by default) to continue a single instruction onto the next line. This makes it easier to use with longer commands, because it lets you split them up into multiple lines. For example, consider these two lines:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIHNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIFwKZWNobyAkSE9NRQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&&</span> <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span><span class=nb>echo</span> <span class=nv>$HOME</span></span></span></code></pre></div></div></div></div><p>They're equivalent to the following line:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIHNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIGVjaG8gJEhPTUU=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&&</span> <span class=nb>echo</span> <span class=nv>$HOME</span></span></span></code></pre></div></div></div></div><p>You can also use heredocs with the shell form to break up supported commands.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIDw8RU9GCnNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIFwKZWNobyAkSE9NRQpFT0Y=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <<EOF<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&&</span> <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span><span class=nb>echo</span> <span class=nv>$HOME</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div></div><p>For more information about heredocs, see <a class=link href=#here-documents>Here-documents</a>.</p><h3 class=scroll-mt-20 id=use-a-different-shell><a class="text-black dark:text-white no-underline hover:underline" href=#use-a-different-shell>Use a different shell</a></h3><p>You can change the default shell using the <code>SHELL</code> command. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'U0hFTEwgWyIvYmluL2Jhc2giLCAiLWMiXQpSVU4gZWNobyBoZWxsbw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>SHELL</span> <span class=p>[</span><span class=s2>"/bin/bash"</span><span class=p>,</span> <span class=s2>"-c"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div></div><p>For more information, see <a class=link href=#shell>SHELL</a>.</p><h2 class=scroll-mt-20 id=from><a class="text-black dark:text-white no-underline hover:underline" href=#from>FROM</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+IFtBUyA8bmFtZT5d', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=<platform>] <image> [AS <name>]</span></span></span></code></pre></div></div></div></div><p>Or</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+Wzo8dGFnPl0gW0FTIDxuYW1lPl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=<platform>] <image>[:<tag>] [AS <name>]</span></span></span></code></pre></div></div></div></div><p>Or</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+W0A8ZGlnZXN0Pl0gW0FTIDxuYW1lPl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=<platform>] <image>[@<digest>] [AS <name>]</span></span></span></code></pre></div></div></div></div><p>The <code>FROM</code> instruction initializes a new build stage and sets the <a class=link href=https://docs.docker.com/glossary/#base-image rel=noopener>base image<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> for subsequent instructions. As such, a valid Dockerfile must start with a <code>FROM</code> instruction. The image can be any valid image.</p><ul><li><code>ARG</code> is the only instruction that may precede <code>FROM</code> in the Dockerfile. See <a class=link href=#understand-how-arg-and-from-interact>Understand how ARG and FROM interact</a>.</li><li><code>FROM</code> can appear multiple times within a single Dockerfile to create multiple images or use one build stage as a dependency for another. Simply make a note of the last image ID output by the commit before each new <code>FROM</code> instruction. Each <code>FROM</code> instruction clears any state created by previous instructions.</li><li>Optionally a name can be given to a new build stage by adding <code>AS name</code> to the <code>FROM</code> instruction. The name can be used in subsequent <code>FROM <name></code>, <a class=link href=#copy---from><code>COPY --from=<name></code></a>, and <a class=link href=#run---mounttypebind><code>RUN --mount=type=bind,from=<name></code></a> instructions to refer to the image built in this stage.</li><li>The <code>tag</code> or <code>digest</code> values are optional. If you omit either of them, the builder assumes a <code>latest</code> tag by default. The builder returns an error if it can't find the <code>tag</code> value.</li></ul><p>The optional <code>--platform</code> flag can be used to specify the platform of the image in case <code>FROM</code> references a multi-platform image. For example, <code>linux/amd64</code>, <code>linux/arm64</code>, or <code>windows/amd64</code>. By default, the target platform of the build request is used. Global build arguments can be used in the value of this flag, for example <a class=link href=#automatic-platform-args-in-the-global-scope>automatic platform ARGs</a> allow you to force a stage to native build platform (<code>--platform=$BUILDPLATFORM</code>), and use it to cross-compile to the target platform inside the stage.</p><h3 class=scroll-mt-20 id=understand-how-arg-and-from-interact><a class="text-black dark:text-white no-underline hover:underline" href=#understand-how-arg-and-from-interact>Understand how ARG and FROM interact</a></h3><p><code>FROM</code> instructions support variables that are declared by any <code>ARG</code> instructions that occur before the first <code>FROM</code>.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QVJHICBDT0RFX1ZFUlNJT049bGF0ZXN0CkZST00gYmFzZToke0NPREVfVkVSU0lPTn0KQ01EICAvY29kZS9ydW4tYXBwCgpGUk9NIGV4dHJhczoke0NPREVfVkVSU0lPTn0KQ01EICAvY29kZS9ydW4tZXh0cmFz', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>CODE_VERSION</span><span class=o>=</span>latest </span></span><span class=line><span class=cl><span class=k>FROM</span><span class=s> base:${CODE_VERSION}</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> /code/run-app<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> extras:${CODE_VERSION}</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> /code/run-extras</span></span></code></pre></div></div></div></div><p>An <code>ARG</code> declared before a <code>FROM</code> is outside of a build stage, so it can't be used in any instruction after a <code>FROM</code>. To use the default value of an <code>ARG</code> declared before the first <code>FROM</code> use an <code>ARG</code> instruction without a value inside of a build stage:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QVJHIFZFUlNJT049bGF0ZXN0CkZST00gYnVzeWJveDokVkVSU0lPTgpBUkcgVkVSU0lPTgpSVU4gZWNobyAkVkVSU0lPTiA+IGltYWdlX3ZlcnNpb24=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>VERSION</span><span class=o>=</span>latest </span></span><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox:$VERSION</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> VERSION<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$VERSION</span> > image_version</span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=run><a class="text-black dark:text-white no-underline hover:underline" href=#run>RUN</a></h2><p>The <code>RUN</code> instruction will execute any commands to create a new layer on top of the current image. The added layer is used in the next step in the Dockerfile. <code>RUN</code> has two forms:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBTaGVsbCBmb3JtOgpSVU4gW09QVElPTlNdIDxjb21tYW5kPiAuLi4KIyBFeGVjIGZvcm06ClJVTiBbT1BUSU9OU10gWyAiPGNvbW1hbmQ+IiwgLi4uIF0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># Shell form:</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <command> ...<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Exec form:</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <span class=o>[</span> <span class=s2>"<command>"</span>, ... <span class=o>]</span></span></span></code></pre></div></div></div></div><p>For more information about the differences between these two forms, see <a class=link href=#shell-and-exec-form>shell or exec forms</a>.</p><p>The shell form is most commonly used, and lets you break up longer instructions into multiple lines, either using newline <a class=link href=#escape>escapes</a>, or with <a class=link href=#here-documents>heredocs</a>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIDw8RU9GCmFwdC1nZXQgdXBkYXRlCmFwdC1nZXQgaW5zdGFsbCAteSBjdXJsCkVPRg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <<EOF<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>apt-get update<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>apt-get install -y curl<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div></div><p>The available <code>[OPTIONS]</code> for the <code>RUN</code> instruction are:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Minimum Dockerfile version</th></tr></thead><tbody><tr><td class=p-2><a class=link href=#run---mount><code>--mount</code></a></td><td class=p-2>1.2</td></tr><tr><td class=p-2><a class=link href=#run---network><code>--network</code></a></td><td class=p-2>1.3</td></tr><tr><td class=p-2><a class=link href=#run---security><code>--security</code></a></td><td class=p-2>1.1.2-labs</td></tr></tbody></table></div><h3 class=scroll-mt-20 id=cache-invalidation-for-run-instructions><a class="text-black dark:text-white no-underline hover:underline" href=#cache-invalidation-for-run-instructions>Cache invalidation for RUN instructions</a></h3><p>The cache for <code>RUN</code> instructions isn't invalidated automatically during the next build. The cache for an instruction like <code>RUN apt-get dist-upgrade -y</code> will be reused during the next build. The cache for <code>RUN</code> instructions can be invalidated by using the <code>--no-cache</code> flag, for example <code>docker build --no-cache</code>.</p><p>See the <a class=link href=https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ rel=noopener>Dockerfile Best Practices guide<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> for more information.</p><p>The cache for <code>RUN</code> instructions can be invalidated by <a class=link href=#add><code>ADD</code></a> and <a class=link href=#copy><code>COPY</code></a> instructions.</p><h3 class=scroll-mt-20 id=run---mount><a class="text-black dark:text-white no-underline hover:underline" href=#run---mount>RUN --mount</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIC0tbW91bnQ9W3R5cGU9PFRZUEU+XVssb3B0aW9uPTx2YWx1ZT5bLG9wdGlvbj08dmFsdWU+XS4uLl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> --mount<span class=o>=[</span><span class=nv>type</span><span class=o>=</span><TYPE><span class=o>][</span>,option<span class=o>=</span><value><span class=o>[</span>,option<span class=o>=</span><value><span class=o>]</span>...<span class=o>]</span></span></span></code></pre></div></div></div></div><p><code>RUN --mount</code> allows you to create filesystem mounts that the build can access. This can be used to:</p><ul><li>Create bind mount to the host filesystem or other build stages</li><li>Access build secrets or ssh-agent sockets</li><li>Use a persistent package management cache to speed up your build</li></ul><p>The supported mount types are:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Type</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><a class=link href=#run---mounttypebind><code>bind</code></a> (default)</td><td class=p-2>Bind-mount context directories (read-only).</td></tr><tr><td class=p-2><a class=link href=#run---mounttypecache><code>cache</code></a></td><td class=p-2>Mount a temporary directory to cache directories for compilers and package managers.</td></tr><tr><td class=p-2><a class=link href=#run---mounttypetmpfs><code>tmpfs</code></a></td><td class=p-2>Mount a <code>tmpfs</code> in the build container.</td></tr><tr><td class=p-2><a class=link href=#run---mounttypesecret><code>secret</code></a></td><td class=p-2>Allow the build container to access secure files such as private keys without baking them into the image or build cache.</td></tr><tr><td class=p-2><a class=link href=#run---mounttypessh><code>ssh</code></a></td><td class=p-2>Allow the build container to access SSH keys via SSH agents, with support for passphrases.</td></tr></tbody></table></div><h3 class=scroll-mt-20 id=run---mounttypebind><a class="text-black dark:text-white no-underline hover:underline" href=#run---mounttypebind>RUN --mount=type=bind</a></h3><p>This mount type allows binding files or directories to the build container. A bind mount is read-only by default.</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>target</code>, <code>dst</code>, <code>destination</code><sup id=fnref:1><a href=#fn:1 class=footnote-ref role=doc-noteref>1</a></sup></td><td class=p-2>Mount path.</td></tr><tr><td class=p-2><code>source</code></td><td class=p-2>Source path in the <code>from</code>. Defaults to the root of the <code>from</code>.</td></tr><tr><td class=p-2><code>from</code></td><td class=p-2>Build stage, context, or image name for the root of the source. Defaults to the build context.</td></tr><tr><td class=p-2><code>rw</code>,<code>readwrite</code></td><td class=p-2>Allow writes on the mount. Written data will be discarded.</td></tr></tbody></table></div><h3 class=scroll-mt-20 id=run---mounttypecache><a class="text-black dark:text-white no-underline hover:underline" href=#run---mounttypecache>RUN --mount=type=cache</a></h3><p>This mount type allows the build container to cache directories for compilers and package managers.</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>id</code></td><td class=p-2>Optional ID to identify separate/different caches. Defaults to value of <code>target</code>.</td></tr><tr><td class=p-2><code>target</code>, <code>dst</code>, <code>destination</code><sup id=fnref1:1><a href=#fn:1 class=footnote-ref role=doc-noteref>1</a></sup></td><td class=p-2>Mount path.</td></tr><tr><td class=p-2><code>ro</code>,<code>readonly</code></td><td class=p-2>Read-only if set.</td></tr><tr><td class=p-2><code>sharing</code></td><td class=p-2>One of <code>shared</code>, <code>private</code>, or <code>locked</code>. Defaults to <code>shared</code>. A <code>shared</code> cache mount can be used concurrently by multiple writers. <code>private</code> creates a new mount if there are multiple writers. <code>locked</code> pauses the second writer until the first one releases the mount.</td></tr><tr><td class=p-2><code>from</code></td><td class=p-2>Build stage, context, or image name to use as a base of the cache mount. Defaults to empty directory.</td></tr><tr><td class=p-2><code>source</code></td><td class=p-2>Subpath in the <code>from</code> to mount. Defaults to the root of the <code>from</code>.</td></tr><tr><td class=p-2><code>mode</code></td><td class=p-2>File mode for new cache directory in octal. Default <code>0755</code>.</td></tr><tr><td class=p-2><code>uid</code></td><td class=p-2>User ID for new cache directory. Default <code>0</code>.</td></tr><tr><td class=p-2><code>gid</code></td><td class=p-2>Group ID for new cache directory. Default <code>0</code>.</td></tr></tbody></table></div><p>Contents of the cache directories persists between builder invocations without invalidating the instruction cache. Cache mounts should only be used for better performance. Your build should work with any contents of the cache directory as another build may overwrite the files or GC may clean it if more storage space is needed.</p><h4 class=scroll-mt-20 id=example-cache-go-packages><a class="text-black dark:text-white no-underline hover:underline" href=#example-cache-go-packages>Example: cache Go packages</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGdvbGFuZwpSVU4gLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vcm9vdC8uY2FjaGUvZ28tYnVpbGQgXAogIGdvIGJ1aWxkIC4uLg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> golang</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/root/.cache/go-build <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> go build ...</span></span></code></pre></div></div></div></div><h4 class=scroll-mt-20 id=example-cache-apt-packages><a class="text-black dark:text-white no-underline hover:underline" href=#example-cache-apt-packages>Example: cache apt packages</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHVidW50dQpSVU4gcm0gLWYgL2V0Yy9hcHQvYXB0LmNvbmYuZC9kb2NrZXItY2xlYW47IGVjaG8gJ0JpbmFyeTo6YXB0OjpBUFQ6OktlZXAtRG93bmxvYWRlZC1QYWNrYWdlcyAidHJ1ZSI7JyA+IC9ldGMvYXB0L2FwdC5jb25mLmQva2VlcC1jYWNoZQpSVU4gLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vdmFyL2NhY2hlL2FwdCxzaGFyaW5nPWxvY2tlZCBcCiAgLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vdmFyL2xpYi9hcHQsc2hhcmluZz1sb2NrZWQgXAogIGFwdCB1cGRhdGUgJiYgYXB0LWdldCAtLW5vLWluc3RhbGwtcmVjb21tZW5kcyBpbnN0YWxsIC15IGdjYw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> rm -f /etc/apt/apt.conf.d/docker-clean<span class=p>;</span> <span class=nb>echo</span> <span class=s1>'Binary::apt::APT::Keep-Downloaded-Packages "true";'</span> > /etc/apt/apt.conf.d/keep-cache<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/var/cache/apt,sharing<span class=o>=</span>locked <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/var/lib/apt,sharing<span class=o>=</span>locked <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> apt update <span class=o>&&</span> apt-get --no-install-recommends install -y gcc</span></span></code></pre></div></div></div></div><p>Apt needs exclusive access to its data, so the caches use the option <code>sharing=locked</code>, which will make sure multiple parallel builds using the same cache mount will wait for each other and not access the same cache files at the same time. You could also use <code>sharing=private</code> if you prefer to have each build create another cache directory in this case.</p><h3 class=scroll-mt-20 id=run---mounttypetmpfs><a class="text-black dark:text-white no-underline hover:underline" href=#run---mounttypetmpfs>RUN --mount=type=tmpfs</a></h3><p>This mount type allows mounting <code>tmpfs</code> in the build container.</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>target</code>, <code>dst</code>, <code>destination</code><sup id=fnref2:1><a href=#fn:1 class=footnote-ref role=doc-noteref>1</a></sup></td><td class=p-2>Mount path.</td></tr><tr><td class=p-2><code>size</code></td><td class=p-2>Specify an upper limit on the size of the filesystem.</td></tr></tbody></table></div><h3 class=scroll-mt-20 id=run---mounttypesecret><a class="text-black dark:text-white no-underline hover:underline" href=#run---mounttypesecret>RUN --mount=type=secret</a></h3><p>This mount type allows the build container to access secret values, such as tokens or private keys, without baking them into the image.</p><p>By default, the secret is mounted as a file. You can also mount the secret as an environment variable by setting the <code>env</code> option.</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>id</code></td><td class=p-2>ID of the secret. Defaults to basename of the target path.</td></tr><tr><td class=p-2><code>target</code>, <code>dst</code>, <code>destination</code></td><td class=p-2>Mount the secret to the specified path. Defaults to <code>/run/secrets/</code> + <code>id</code> if unset and if <code>env</code> is also unset.</td></tr><tr><td class=p-2><code>env</code></td><td class=p-2>Mount the secret to an environment variable instead of a file, or both. (since Dockerfile v1.10.0)</td></tr><tr><td class=p-2><code>required</code></td><td class=p-2>If set to <code>true</code>, the instruction errors out when the secret is unavailable. Defaults to <code>false</code>.</td></tr><tr><td class=p-2><code>mode</code></td><td class=p-2>File mode for secret file in octal. Default <code>0400</code>.</td></tr><tr><td class=p-2><code>uid</code></td><td class=p-2>User ID for secret file. Default <code>0</code>.</td></tr><tr><td class=p-2><code>gid</code></td><td class=p-2>Group ID for secret file. Default <code>0</code>.</td></tr></tbody></table></div><h4 class=scroll-mt-20 id=example-access-to-s3><a class="text-black dark:text-white no-underline hover:underline" href=#example-access-to-s3>Example: access to S3</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozClJVTiBwaXAgaW5zdGFsbCBhd3NjbGkKUlVOIC0tbW91bnQ9dHlwZT1zZWNyZXQsaWQ9YXdzLHRhcmdldD0vcm9vdC8uYXdzL2NyZWRlbnRpYWxzIFwKICBhd3MgczMgY3AgczM6Ly8uLi4gLi4u', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pip install awscli<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>secret,id<span class=o>=</span>aws,target<span class=o>=</span>/root/.aws/credentials <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> aws s3 cp s3://... ...</span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGR4IGJ1aWxkIC0tc2VjcmV0IGlkPWF3cyxzcmM9JEhPTUUvLmF3cy9jcmVkZW50aWFscyAu', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker buildx build --secret <span class=nv>id</span><span class=o>=</span>aws,src<span class=o>=</span><span class=nv>$HOME</span>/.aws/credentials . </span></span></code></pre></div></div></div></div><h4 class=scroll-mt-20 id=example-mount-as-environment-variable><a class="text-black dark:text-white no-underline hover:underline" href=#example-mount-as-environment-variable>Example: Mount as environment variable</a></h4><p>The following example takes the secret <code>API_KEY</code> and mounts it as an environment variable with the same name.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpSVU4gLS1tb3VudD10eXBlPXNlY3JldCxpZD1BUElfS0VZLGVudj1BUElfS0VZIFwKICAgIHNvbWUtY29tbWFuZCAtLXRva2VuLWZyb20tZW52ICRBUElfS0VZ', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>secret,id<span class=o>=</span>API_KEY,env<span class=o>=</span>API_KEY <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> some-command --token-from-env <span class=nv>$API_KEY</span></span></span></code></pre></div></div></div></div><p>Assuming that the <code>API_KEY</code> environment variable is set in the build environment, you can build this with the following command:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGR4IGJ1aWxkIC0tc2VjcmV0IGlkPUFQSV9LRVkgLg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker buildx build --secret <span class=nv>id</span><span class=o>=</span>API_KEY . </span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=run---mounttypessh><a class="text-black dark:text-white no-underline hover:underline" href=#run---mounttypessh>RUN --mount=type=ssh</a></h3><p>This mount type allows the build container to access SSH keys via SSH agents, with support for passphrases.</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>id</code></td><td class=p-2>ID of SSH agent socket or key. Defaults to "default".</td></tr><tr><td class=p-2><code>target</code>, <code>dst</code>, <code>destination</code></td><td class=p-2>SSH agent socket path. Defaults to <code>/run/buildkit/ssh_agent.${N}</code>.</td></tr><tr><td class=p-2><code>required</code></td><td class=p-2>If set to <code>true</code>, the instruction errors out when the key is unavailable. Defaults to <code>false</code>.</td></tr><tr><td class=p-2><code>mode</code></td><td class=p-2>File mode for socket in octal. Default <code>0600</code>.</td></tr><tr><td class=p-2><code>uid</code></td><td class=p-2>User ID for socket. Default <code>0</code>.</td></tr><tr><td class=p-2><code>gid</code></td><td class=p-2>Group ID for socket. Default <code>0</code>.</td></tr></tbody></table></div><h4 class=scroll-mt-20 id=example-access-to-gitlab><a class="text-black dark:text-white no-underline hover:underline" href=#example-access-to-gitlab>Example: access to GitLab</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpSVU4gYXBrIGFkZCAtLW5vLWNhY2hlIG9wZW5zc2gtY2xpZW50ClJVTiBta2RpciAtcCAtbSAwNzAwIH4vLnNzaCAmJiBzc2gta2V5c2NhbiBnaXRsYWIuY29tID4+IH4vLnNzaC9rbm93bl9ob3N0cwpSVU4gLS1tb3VudD10eXBlPXNzaCBcCiAgc3NoIC1xIC1UIGdpdEBnaXRsYWIuY29tIDI+JjEgfCB0ZWUgL2hlbGxvCiMgIldlbGNvbWUgdG8gR2l0TGFiLCBAR0lUTEFCX1VTRVJOQU1FX0FTU09DSUFURURfV0lUSF9TU0hLRVkiIHNob3VsZCBiZSBwcmludGVkIGhlcmUKIyB3aXRoIHRoZSB0eXBlIG9mIGJ1aWxkIHByb2dyZXNzIGlzIGRlZmluZWQgYXMgYHBsYWluYC4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apk add --no-cache openssh-client<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> mkdir -p -m <span class=m>0700</span> ~/.ssh <span class=o>&&</span> ssh-keyscan gitlab.com >> ~/.ssh/known_hosts<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>ssh <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> ssh -q -T git@gitlab.com 2><span class=p>&</span><span class=m>1</span> <span class=p>|</span> tee /hello<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># "Welcome to GitLab, @GITLAB_USERNAME_ASSOCIATED_WITH_SSHKEY" should be printed here</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># with the type of build progress is defined as `plain`.</span></span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBldmFsICQoc3NoLWFnZW50KQokIHNzaC1hZGQgfi8uc3NoL2lkX3JzYQooSW5wdXQgeW91ciBwYXNzcGhyYXNlIGhlcmUpCiQgZG9ja2VyIGJ1aWxkeCBidWlsZCAtLXNzaCBkZWZhdWx0PSRTU0hfQVVUSF9TT0NLIC4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> <span class=nb>eval</span> <span class=k>$(</span>ssh-agent<span class=k>)</span> </span></span><span class=line><span class=cl><span class=gp>$</span> ssh-add ~/.ssh/id_rsa </span></span><span class=line><span class=cl><span class=go>(Input your passphrase here) </span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>$</span> docker buildx build --ssh <span class=nv>default</span><span class=o>=</span><span class=nv>$SSH_AUTH_SOCK</span> . </span></span></code></pre></div></div></div></div><p>You can also specify a path to <code>*.pem</code> file on the host directly instead of <code>$SSH_AUTH_SOCK</code>. However, pem files with passphrases are not supported.</p><h3 class=scroll-mt-20 id=run---network><a class="text-black dark:text-white no-underline hover:underline" href=#run---network>RUN --network</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIC0tbmV0d29yaz08VFlQRT4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> --network<span class=o>=</span><TYPE></span></span></code></pre></div></div></div></div><p><code>RUN --network</code> allows control over which networking environment the command is run in.</p><p>The supported network types are:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Type</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><a class=link href=#run---networkdefault><code>default</code></a> (default)</td><td class=p-2>Run in the default network.</td></tr><tr><td class=p-2><a class=link href=#run---networknone><code>none</code></a></td><td class=p-2>Run with no network access.</td></tr><tr><td class=p-2><a class=link href=#run---networkhost><code>host</code></a></td><td class=p-2>Run in the host's network environment.</td></tr></tbody></table></div><h3 class=scroll-mt-20 id=run---networkdefault><a class="text-black dark:text-white no-underline hover:underline" href=#run---networkdefault>RUN --network=default</a></h3><p>Equivalent to not supplying a flag at all, the command is run in the default network for the build.</p><h3 class=scroll-mt-20 id=run---networknone><a class="text-black dark:text-white no-underline hover:underline" href=#run---networknone>RUN --network=none</a></h3><p>The command is run with no network access (<code>lo</code> is still available, but is isolated to this process)</p><h4 class=scroll-mt-20 id=example-isolating-external-effects><a class="text-black dark:text-white no-underline hover:underline" href=#example-isolating-external-effects>Example: isolating external effects</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozLjYKQUREIG15cGFja2FnZS50Z3ogd2hlZWxzLwpSVU4gLS1uZXR3b3JrPW5vbmUgcGlwIGluc3RhbGwgLS1maW5kLWxpbmtzIHdoZWVscyBteXBhY2thZ2U=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3.6</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> mypackage.tgz wheels/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --network<span class=o>=</span>none pip install --find-links wheels mypackage</span></span></code></pre></div></div></div></div><p><code>pip</code> will only be able to install the packages provided in the tarfile, which can be controlled by an earlier build stage.</p><h3 class=scroll-mt-20 id=run---networkhost><a class="text-black dark:text-white no-underline hover:underline" href=#run---networkhost>RUN --network=host</a></h3><p>The command is run in the host's network environment (similar to <code>docker build --network=host</code>, but on a per-instruction basis)</p><blockquote class="px-4 border-l-4 border-amber-light dark:border-amber-dark"><p class="flex gap-2 items-center text-amber-light dark:text-amber-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M92-120q-9 0-15.65-4.13Q69.7-128.25 66-135q-4.17-6.6-4.58-14.3Q61-157 66-165l388-670q5-8 11.5-11.5T480-850t14.5 3.5T506-835l388 670q5 8 4.58 15.7-.41 7.7-4.58 14.3-3.7 6.75-10.35 10.87Q877-120 868-120H92zm392.18-117q12.82.0 21.32-8.68 8.5-8.67 8.5-21.5.0-12.82-8.68-21.32-8.67-8.5-21.5-8.5-12.82.0-21.32 8.68-8.5 8.67-8.5 21.5.0 12.82 8.68 21.32 8.67 8.5 21.5 8.5zm0-111q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-164q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v164q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63z"/></svg> </span><strong>Warning</strong></p><p>The use of <code>--network=host</code> is protected by the <code>network.host</code> entitlement, which needs to be enabled when starting the buildkitd daemon with <code>--allow-insecure-entitlement network.host</code> flag or in <a class=link href=https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md rel=noopener>buildkitd config<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>, and for a build request with <a class=link href=https://docs.docker.com/engine/reference/commandline/buildx_build/#allow rel=noopener><code>--allow network.host</code> flag<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p></blockquote><h3 class=scroll-mt-20 id=run---security><a class="text-black dark:text-white no-underline hover:underline" href=#run---security>RUN --security</a></h3><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Not yet available in stable syntax, use <a class=link href=#syntax><code>docker/dockerfile:1-labs</code></a> version.</p></blockquote><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIC0tc2VjdXJpdHk9PHNhbmRib3h8aW5zZWN1cmU+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> --security<span class=o>=</span><sandbox<span class=p>|</span>insecure></span></span></code></pre></div></div></div></div><p>The default security mode is <code>sandbox</code>. With <code>--security=insecure</code>, the builder runs the command without sandbox in insecure mode, which allows to run flows requiring elevated privileges (e.g. containerd). This is equivalent to running <code>docker run --privileged</code>.</p><blockquote class="px-4 border-l-4 border-amber-light dark:border-amber-dark"><p class="flex gap-2 items-center text-amber-light dark:text-amber-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M92-120q-9 0-15.65-4.13Q69.7-128.25 66-135q-4.17-6.6-4.58-14.3Q61-157 66-165l388-670q5-8 11.5-11.5T480-850t14.5 3.5T506-835l388 670q5 8 4.58 15.7-.41 7.7-4.58 14.3-3.7 6.75-10.35 10.87Q877-120 868-120H92zm392.18-117q12.82.0 21.32-8.68 8.5-8.67 8.5-21.5.0-12.82-8.68-21.32-8.67-8.5-21.5-8.5-12.82.0-21.32 8.68-8.5 8.67-8.5 21.5.0 12.82 8.68 21.32 8.67 8.5 21.5 8.5zm0-111q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-164q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v164q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63z"/></svg> </span><strong>Warning</strong></p><p>In order to access this feature, entitlement <code>security.insecure</code> should be enabled when starting the buildkitd daemon with <code>--allow-insecure-entitlement security.insecure</code> flag or in <a class=link href=https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md rel=noopener>buildkitd config<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>, and for a build request with <a class=link href=https://docs.docker.com/engine/reference/commandline/buildx_build/#allow rel=noopener><code>--allow security.insecure</code> flag<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p></blockquote><p>Default sandbox mode can be activated via <code>--security=sandbox</code>, but that is no-op.</p><h4 class=scroll-mt-20 id=example-check-entitlements><a class="text-black dark:text-white no-underline hover:underline" href=#example-check-entitlements>Example: check entitlements</a></h4><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gdWJ1bnR1ClJVTiAtLXNlY3VyaXR5PWluc2VjdXJlIGNhdCAvcHJvYy9zZWxmL3N0YXR1cyB8IGdyZXAgQ2FwRWZm', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --security<span class=o>=</span>insecure cat /proc/self/status <span class=p>|</span> grep CapEff</span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Izg0IDAuMDkzIENhcEVmZjoJMDAwMDAwM2ZmZmZmZmZmZg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-text data-lang=text><span class=line><span class=cl>#84 0.093 CapEff: 0000003fffffffff</span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=cmd><a class="text-black dark:text-white no-underline hover:underline" href=#cmd>CMD</a></h2><p>The <code>CMD</code> instruction sets the command to be executed when running a container from an image.</p><p>You can specify <code>CMD</code> instructions using <a class=link href=#shell-and-exec-form>shell or exec forms</a>:</p><ul><li><code>CMD ["executable","param1","param2"]</code> (exec form)</li><li><code>CMD ["param1","param2"]</code> (exec form, as default parameters to <code>ENTRYPOINT</code>)</li><li><code>CMD command param1 param2</code> (shell form)</li></ul><p>There can only be one <code>CMD</code> instruction in a Dockerfile. If you list more than one <code>CMD</code>, only the last one takes effect.</p><p>The purpose of a <code>CMD</code> is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an <code>ENTRYPOINT</code> instruction as well.</p><p>If you would like your container to run the same executable every time, then you should consider using <code>ENTRYPOINT</code> in combination with <code>CMD</code>. See <a class=link href=#entrypoint><code>ENTRYPOINT</code></a>. If the user specifies arguments to <code>docker run</code> then they will override the default specified in <code>CMD</code>, but still use the default <code>ENTRYPOINT</code>.</p><p>If <code>CMD</code> is used to provide default arguments for the <code>ENTRYPOINT</code> instruction, both the <code>CMD</code> and <code>ENTRYPOINT</code> instructions should be specified in the <a class=link href=#exec-form>exec form</a>.</p><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Don't confuse <code>RUN</code> with <code>CMD</code>. <code>RUN</code> actually runs a command and commits the result; <code>CMD</code> doesn't execute anything at build time, but specifies the intended command for the image.</p></blockquote><h2 class=scroll-mt-20 id=label><a class="text-black dark:text-white no-underline hover:underline" href=#label>LABEL</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TEFCRUwgPGtleT49PHZhbHVlPiBbPGtleT49PHZhbHVlPi4uLl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> <key><span class=o>=</span><value> <span class=o>[</span><key><span class=o>=</span><value>...<span class=o>]</span></span></span></code></pre></div></div></div></div><p>The <code>LABEL</code> instruction adds metadata to an image. A <code>LABEL</code> is a key-value pair. To include spaces within a <code>LABEL</code> value, use quotes and backslashes as you would in command-line parsing. A few usage examples:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TEFCRUwgImNvbS5leGFtcGxlLnZlbmRvciI9IkFDTUUgSW5jb3Jwb3JhdGVkIgpMQUJFTCBjb20uZXhhbXBsZS5sYWJlbC13aXRoLXZhbHVlPSJmb28iCkxBQkVMIHZlcnNpb249IjEuMCIKTEFCRUwgZGVzY3JpcHRpb249IlRoaXMgdGV4dCBpbGx1c3RyYXRlcyBcCnRoYXQgbGFiZWwtdmFsdWVzIGNhbiBzcGFuIG11bHRpcGxlIGxpbmVzLiI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> <span class=s2>"com.example.vendor"</span><span class=o>=</span><span class=s2>"ACME Incorporated"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> com.example.label-with-value<span class=o>=</span><span class=s2>"foo"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> <span class=nv>version</span><span class=o>=</span><span class=s2>"1.0"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> <span class=nv>description</span><span class=o>=</span><span class=s2>"This text illustrates \ </span></span></span><span class=line><span class=cl><span class=s2>that label-values can span multiple lines."</span></span></span></code></pre></div></div></div></div><p>An image can have more than one label. You can specify multiple labels on a single line. Prior to Docker 1.10, this decreased the size of the final image, but this is no longer the case. You may still choose to specify multiple labels in a single instruction, in one of the following two ways:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TEFCRUwgbXVsdGkubGFiZWwxPSJ2YWx1ZTEiIG11bHRpLmxhYmVsMj0idmFsdWUyIiBvdGhlcj0idmFsdWUzIg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> multi.label1<span class=o>=</span><span class=s2>"value1"</span> multi.label2<span class=o>=</span><span class=s2>"value2"</span> <span class=nv>other</span><span class=o>=</span><span class=s2>"value3"</span></span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TEFCRUwgbXVsdGkubGFiZWwxPSJ2YWx1ZTEiIFwKICAgICAgbXVsdGkubGFiZWwyPSJ2YWx1ZTIiIFwKICAgICAgb3RoZXI9InZhbHVlMyI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> multi.label1<span class=o>=</span><span class=s2>"value1"</span> <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> multi.label2<span class=o>=</span><span class=s2>"value2"</span> <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> <span class=nv>other</span><span class=o>=</span><span class=s2>"value3"</span></span></span></code></pre></div></div></div></div><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Be sure to use double quotes and not single quotes. Particularly when you are using string interpolation (e.g. <code>LABEL example="foo-$ENV_VAR"</code>), single quotes will take the string as is without unpacking the variable's value.</p></blockquote><p>Labels included in base images (images in the <code>FROM</code> line) are inherited by your image. If a label already exists but with a different value, the most-recently-applied value overrides any previously-set value.</p><p>To view an image's labels, use the <code>docker image inspect</code> command. You can use the <code>--format</code> option to show just the labels;</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgaW1hZ2UgaW5zcGVjdCAtLWZvcm1hdD0ne3tqc29uIC5Db25maWcuTGFiZWxzfX0nIG15aW1hZ2U=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker image inspect --format<span class=o>=</span><span class=s1>'{{json .Config.Labels}}'</span> myimage </span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'ewogICJjb20uZXhhbXBsZS52ZW5kb3IiOiAiQUNNRSBJbmNvcnBvcmF0ZWQiLAogICJjb20uZXhhbXBsZS5sYWJlbC13aXRoLXZhbHVlIjogImZvbyIsCiAgInZlcnNpb24iOiAiMS4wIiwKICAiZGVzY3JpcHRpb24iOiAiVGhpcyB0ZXh0IGlsbHVzdHJhdGVzIHRoYXQgbGFiZWwtdmFsdWVzIGNhbiBzcGFuIG11bHRpcGxlIGxpbmVzLiIsCiAgIm11bHRpLmxhYmVsMSI6ICJ2YWx1ZTEiLAogICJtdWx0aS5sYWJlbDIiOiAidmFsdWUyIiwKICAib3RoZXIiOiAidmFsdWUzIgp9', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-json data-lang=json><span class=line><span class=cl><span class=p>{</span> </span></span><span class=line><span class=cl> <span class=nt>"com.example.vendor"</span><span class=p>:</span> <span class=s2>"ACME Incorporated"</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"com.example.label-with-value"</span><span class=p>:</span> <span class=s2>"foo"</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"version"</span><span class=p>:</span> <span class=s2>"1.0"</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"description"</span><span class=p>:</span> <span class=s2>"This text illustrates that label-values can span multiple lines."</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"multi.label1"</span><span class=p>:</span> <span class=s2>"value1"</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"multi.label2"</span><span class=p>:</span> <span class=s2>"value2"</span><span class=p>,</span> </span></span><span class=line><span class=cl> <span class=nt>"other"</span><span class=p>:</span> <span class=s2>"value3"</span> </span></span><span class=line><span class=cl><span class=p>}</span></span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=maintainer-deprecated><a class="text-black dark:text-white no-underline hover:underline" href=#maintainer-deprecated>MAINTAINER (deprecated)</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TUFJTlRBSU5FUiA8bmFtZT4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>MAINTAINER</span><span class=s> <name></span></span></span></code></pre></div></div></div></div><p>The <code>MAINTAINER</code> instruction sets the <em>Author</em> field of the generated images. The <code>LABEL</code> instruction is a much more flexible version of this and you should use it instead, as it enables setting any metadata you require, and can be viewed easily, for example with <code>docker inspect</code>. To set a label corresponding to the <code>MAINTAINER</code> field you could use:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'TEFCRUwgb3JnLm9wZW5jb250YWluZXJzLmltYWdlLmF1dGhvcnM9IlN2ZW5Eb3dpZGVpdEBob21lLm9yZy5hdSI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> org.opencontainers.image.authors<span class=o>=</span><span class=s2>"SvenDowideit@home.org.au"</span></span></span></code></pre></div></div></div></div><p>This will then be visible from <code>docker inspect</code> with the other labels.</p><h2 class=scroll-mt-20 id=expose><a class="text-black dark:text-white no-underline hover:underline" href=#expose>EXPOSE</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDxwb3J0PiBbPHBvcnQ+Lzxwcm90b2NvbD4uLi5d', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> <port> [<port>/<protocol>...]</span></span></span></code></pre></div></div></div></div><p>The <code>EXPOSE</code> instruction informs Docker that the container listens on the specified network ports at runtime. You can specify whether the port listens on TCP or UDP, and the default is TCP if you don't specify a protocol.</p><p>The <code>EXPOSE</code> instruction doesn't actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To publish the port when running the container, use the <code>-p</code> flag on <code>docker run</code> to publish and map one or more ports, or the <code>-P</code> flag to publish all exposed ports and map them to high-order ports.</p><p>By default, <code>EXPOSE</code> assumes TCP. You can also specify UDP:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDgwL3VkcA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> 80/udp</span></span></span></code></pre></div></div></div></div><p>To expose on both TCP and UDP, include two lines:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDgwL3RjcApFWFBPU0UgODAvdWRw', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> 80/tcp</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>EXPOSE</span><span class=s> 80/udp</span></span></span></code></pre></div></div></div></div><p>In this case, if you use <code>-P</code> with <code>docker run</code>, the port will be exposed once for TCP and once for UDP. Remember that <code>-P</code> uses an ephemeral high-ordered host port on the host, so TCP and UDP doesn't use the same port.</p><p>Regardless of the <code>EXPOSE</code> settings, you can override them at runtime by using the <code>-p</code> flag. For example</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1wIDgwOjgwL3RjcCAtcCA4MDo4MC91ZHAgLi4u', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -p 80:80/tcp -p 80:80/udp ... </span></span></code></pre></div></div></div></div><p>To set up port redirection on the host system, see <a class=link href=https://docs.docker.com/reference/cli/docker/container/run/#publish rel=noopener>using the -P flag<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>. The <code>docker network</code> command supports creating networks for communication among containers without the need to expose or publish specific ports, because the containers connected to the network can communicate with each other over any port. For detailed information, see the <a class=link href=https://docs.docker.com/engine/userguide/networking/ rel=noopener>overview of this feature<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h2 class=scroll-mt-20 id=env><a class="text-black dark:text-white no-underline hover:underline" href=#env>ENV</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIDxrZXk+PTx2YWx1ZT4gWzxrZXk+PTx2YWx1ZT4uLi5d', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <key><span class=o>=</span><value> <span class=o>[</span><key><span class=o>=</span><value>...<span class=o>]</span></span></span></code></pre></div></div></div></div><p>The <code>ENV</code> instruction sets the environment variable <code><key></code> to the value <code><value></code>. This value will be in the environment for all subsequent instructions in the build stage and can be <a class=link href=#environment-replacement>replaced inline</a> in many as well. The value will be interpreted for other environment variables, so quote characters will be removed if they are not escaped. Like command line parsing, quotes and backslashes can be used to include spaces within values.</p><p>Example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX05BTUU9IkpvaG4gRG9lIgpFTlYgTVlfRE9HPVJleFwgVGhlXCBEb2cKRU5WIE1ZX0NBVD1mbHVmZnk=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>MY_NAME</span><span class=o>=</span><span class=s2>"John Doe"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>MY_DOG</span><span class=o>=</span>Rex<span class=se>\ </span>The<span class=se>\ </span>Dog<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>MY_CAT</span><span class=o>=</span>fluffy</span></span></code></pre></div></div></div></div><p>The <code>ENV</code> instruction allows for multiple <code><key>=<value> ...</code> variables to be set at one time, and the example below will yield the same net results in the final image:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX05BTUU9IkpvaG4gRG9lIiBNWV9ET0c9UmV4XCBUaGVcIERvZyBcCiAgICBNWV9DQVQ9Zmx1ZmZ5', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>MY_NAME</span><span class=o>=</span><span class=s2>"John Doe"</span> <span class=nv>MY_DOG</span><span class=o>=</span>Rex<span class=se>\ </span>The<span class=se>\ </span>Dog <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> <span class=nv>MY_CAT</span><span class=o>=</span>fluffy</span></span></code></pre></div></div></div></div><p>The environment variables set using <code>ENV</code> will persist when a container is run from the resulting image. You can view the values using <code>docker inspect</code>, and change them using <code>docker run --env <key>=<value></code>.</p><p>A stage inherits any environment variables that were set using <code>ENV</code> by its parent stage or any ancestor. Refer to the <a class=link href=https://docs.docker.com/build/building/multi-stage/ rel=noopener>multi-stage builds section<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> in the manual for more information.</p><p>Environment variable persistence can cause unexpected side effects. For example, setting <code>ENV DEBIAN_FRONTEND=noninteractive</code> changes the behavior of <code>apt-get</code>, and may confuse users of your image.</p><p>If an environment variable is only needed during build, and not in the final image, consider setting a value for a single command instead:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIERFQklBTl9GUk9OVEVORD1ub25pbnRlcmFjdGl2ZSBhcHQtZ2V0IHVwZGF0ZSAmJiBhcHQtZ2V0IGluc3RhbGwgLXkgLi4u', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nv>DEBIAN_FRONTEND</span><span class=o>=</span>noninteractive apt-get update <span class=o>&&</span> apt-get install -y ...</span></span></code></pre></div></div></div></div><p>Or using <a class=link href=#arg><code>ARG</code></a>, which is not persisted in the final image:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QVJHIERFQklBTl9GUk9OVEVORD1ub25pbnRlcmFjdGl2ZQpSVU4gYXB0LWdldCB1cGRhdGUgJiYgYXB0LWdldCBpbnN0YWxsIC15IC4uLg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>DEBIAN_FRONTEND</span><span class=o>=</span>noninteractive </span></span><span class=line><span class=cl><span class=k>RUN</span> apt-get update <span class=o>&&</span> apt-get install -y ...</span></span></code></pre></div></div></div></div><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p><strong>Alternative syntax</strong></p><p>The <code>ENV</code> instruction also allows an alternative syntax <code>ENV <key> <value></code>, omitting the <code>=</code>. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX1ZBUiBteS12YWx1ZQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> MY_VAR my-value</span></span></code></pre></div></div></div></div><p>This syntax does not allow for multiple environment-variables to be set in a single <code>ENV</code> instruction, and can be confusing. For example, the following sets a single environment variable (<code>ONE</code>) with value <code>"TWO= THREE=world"</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIE9ORSBUV089IFRIUkVFPXdvcmxk', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> ONE <span class=nv>TWO</span><span class=o>=</span> <span class=nv>THREE</span><span class=o>=</span>world</span></span></code></pre></div></div></div></div><p>The alternative syntax is supported for backward compatibility, but discouraged for the reasons outlined above, and may be removed in a future release.</p></blockquote><h2 class=scroll-mt-20 id=add><a class="text-black dark:text-white no-underline hover:underline" href=#add>ADD</a></h2><p>ADD has two forms. The latter form is required for paths containing whitespace.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIFtPUFRJT05TXSA8c3JjPiAuLi4gPGRlc3Q+CkFERCBbT1BUSU9OU10gWyI8c3JjPiIsIC4uLiAiPGRlc3Q+Il0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <src> ... <dest><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <span class=o>[</span><span class=s2>"<src>"</span>, ... <span class=s2>"<dest>"</span><span class=o>]</span></span></span></code></pre></div></div></div></div><p>The available <code>[OPTIONS]</code> are:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Minimum Dockerfile version</th></tr></thead><tbody><tr><td class=p-2><a class=link href=#add---keep-git-dir><code>--keep-git-dir</code></a></td><td class=p-2>1.1</td></tr><tr><td class=p-2><a class=link href=#add---checksum><code>--checksum</code></a></td><td class=p-2>1.6</td></tr><tr><td class=p-2><a class=link href=#add---chown---chmod><code>--chown</code></a></td><td class=p-2></td></tr><tr><td class=p-2><a class=link href=#add---chown---chmod><code>--chmod</code></a></td><td class=p-2>1.2</td></tr><tr><td class=p-2><a class=link href=#add---link><code>--link</code></a></td><td class=p-2>1.4</td></tr><tr><td class=p-2><a class=link href=#add---exclude><code>--exclude</code></a></td><td class=p-2>1.7-labs</td></tr></tbody></table></div><p>The <code>ADD</code> instruction copies new files or directories from <code><src></code> and adds them to the filesystem of the image at the path <code><dest></code>. Files and directories can be copied from the build context, a remote URL, or a Git repository.</p><p>The <code>ADD</code> and <code>COPY</code> instructions are functionally similar, but serve slightly different purposes. Learn more about the <a class=link href=https://docs.docker.com/build/building/best-practices/#add-or-copy rel=noopener>differences between <code>ADD</code> and <code>COPY</code><span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=source><a class="text-black dark:text-white no-underline hover:underline" href=#source>Source</a></h3><p>You can specify multiple source files or directories with <code>ADD</code>. The last argument must always be the destination. For example, to add two files, <code>file1.txt</code> and <code>file2.txt</code>, from the build context to <code>/usr/src/things/</code> in the build container:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGZpbGUxLnR4dCBmaWxlMi50eHQgL3Vzci9zcmMvdGhpbmdzLw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> file1.txt file2.txt /usr/src/things/</span></span></code></pre></div></div></div></div><p>If you specify multiple source files, either directly or using a wildcard, then the destination must be a directory (must end with a slash <code>/</code>).</p><p>To add files from a remote location, you can specify a URL or the address of a Git repository as the source. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGh0dHBzOi8vZXhhbXBsZS5jb20vYXJjaGl2ZS56aXAgL3Vzci9zcmMvdGhpbmdzLwpBREQgZ2l0QGdpdGh1Yi5jb206dXNlci9yZXBvLmdpdCAvdXNyL3NyYy90aGluZ3Mv', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> https://example.com/archive.zip /usr/src/things/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> git@github.com:user/repo.git /usr/src/things/</span></span></code></pre></div></div></div></div><p>BuildKit detects the type of <code><src></code> and processes it accordingly.</p><ul><li>If <code><src></code> is a local file or directory, the contents of the directory are copied to the specified destination. See <a class=link href=#adding-files-from-the-build-context>Adding files from the build context</a>.</li><li>If <code><src></code> is a local tar archive, it is decompressed and extracted to the specified destination. See <a class=link href=#adding-local-tar-archives>Adding local tar archives</a>.</li><li>If <code><src></code> is a URL, the contents of the URL are downloaded and placed at the specified destination. See <a class=link href=#adding-files-from-a-url>Adding files from a URL</a>.</li><li>If <code><src></code> is a Git repository, the repository is cloned to the specified destination. See <a class=link href=#adding-files-from-a-git-repository>Adding files from a Git repository</a>.</li></ul><h4 class=scroll-mt-20 id=adding-files-from-the-build-context><a class="text-black dark:text-white no-underline hover:underline" href=#adding-files-from-the-build-context>Adding files from the build context</a></h4><p>Any relative or local path that doesn't begin with a <code>http://</code>, <code>https://</code>, or <code>git@</code> protocol prefix is considered a local file path. The local file path is relative to the build context. For example, if the build context is the current directory, <code>ADD file.txt /</code> adds the file at <code>./file.txt</code> to the root of the filesystem in the build container.</p><p>Specifying a source path with a leading slash or one that navigates outside the build context, such as <code>ADD ../something /something</code>, automatically removes any parent directory navigation (<code>../</code>). Trailing slashes in the source path are also disregarded, making <code>ADD something/ /something</code> equivalent to <code>ADD something /something</code>.</p><p>If the source is a directory, the contents of the directory are copied, including filesystem metadata. The directory itself isn't copied, only its contents. If it contains subdirectories, these are also copied, and merged with any existing directories at the destination. Any conflicts are resolved in favor of the content being added, on a file-by-file basis, except if you're trying to copy a directory onto an existing file, in which case an error is raised.</p><p>If the source is a file, the file and its metadata are copied to the destination. File permissions are preserved. If the source is a file and a directory with the same name exists at the destination, an error is raised.</p><p>If you pass a Dockerfile through stdin to the build (<code>docker build - < Dockerfile</code>), there is no build context. In this case, you can only use the <code>ADD</code> instruction to copy remote files. You can also pass a tar archive through stdin: (<code>docker build - < archive.tar</code>), the Dockerfile at the root of the archive and the rest of the archive will be used as the context of the build.</p><h5 class=scroll-mt-20 id=pattern-matching><a class="text-black dark:text-white no-underline hover:underline" href=#pattern-matching>Pattern matching</a></h5><p>For local files, each <code><src></code> may contain wildcards and matching will be done using Go's <a class=link href=https://golang.org/pkg/path/filepath#Match rel=noopener>filepath.Match<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> rules.</p><p>For example, to add all files and directories in the root of the build context ending with <code>.png</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREICoucG5nIC9kZXN0Lw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> *.png /dest/</span></span></code></pre></div></div></div></div><p>In the following example, <code>?</code> is a single-character wildcard, matching e.g. <code>index.js</code> and <code>index.ts</code>.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGluZGV4Lj9zIC9kZXN0Lw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> index.?s /dest/</span></span></code></pre></div></div></div></div><p>When adding files or directories that contain special characters (such as <code>[</code> and <code>]</code>), you need to escape those paths following the Golang rules to prevent them from being treated as a matching pattern. For example, to add a file named <code>arr[0].txt</code>, use the following;</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGFycltbXTBdLnR4dCAvZGVzdC8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> arr<span class=o>[[]</span>0<span class=o>]</span>.txt /dest/</span></span></code></pre></div></div></div></div><h4 class=scroll-mt-20 id=adding-local-tar-archives><a class="text-black dark:text-white no-underline hover:underline" href=#adding-local-tar-archives>Adding local tar archives</a></h4><p>When using a local tar archive as the source for <code>ADD</code>, and the archive is in a recognized compression format (<code>gzip</code>, <code>bzip2</code> or <code>xz</code>, or uncompressed), the archive is decompressed and extracted into the specified destination. Only local tar archives are extracted. If the tar archive is a remote URL, the archive is not extracted, but downloaded and placed at the destination.</p><p>When a directory is extracted, it has the same behavior as <code>tar -x</code>. The result is the union of:</p><ol><li>Whatever existed at the destination path, and</li><li>The contents of the source tree, with conflicts resolved in favor of the content being added, on a file-by-file basis.</li></ol><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Whether a file is identified as a recognized compression format or not is done solely based on the contents of the file, not the name of the file. For example, if an empty file happens to end with <code>.tar.gz</code> this isn't recognized as a compressed file and doesn't generate any kind of decompression error message, rather the file will simply be copied to the destination.</p></blockquote><h4 class=scroll-mt-20 id=adding-files-from-a-url><a class="text-black dark:text-white no-underline hover:underline" href=#adding-files-from-a-url>Adding files from a URL</a></h4><p>In the case where source is a remote file URL, the destination will have permissions of 600. If the HTTP response contains a <code>Last-Modified</code> header, the timestamp from that header will be used to set the <code>mtime</code> on the destination file. However, like any other file processed during an <code>ADD</code>, <code>mtime</code> isn't included in the determination of whether or not the file has changed and the cache should be updated.</p><p>If the destination ends with a trailing slash, then the filename is inferred from the URL path. For example, <code>ADD http://example.com/foobar /</code> would create the file <code>/foobar</code>. The URL must have a nontrivial path so that an appropriate filename can be discovered (<code>http://example.com</code> doesn't work).</p><p>If the destination doesn't end with a trailing slash, the destination path becomes the filename of the file downloaded from the URL. For example, <code>ADD http://example.com/foo /bar</code> creates the file <code>/bar</code>.</p><p>If your URL files are protected using authentication, you need to use <code>RUN wget</code>, <code>RUN curl</code> or use another tool from within the container as the <code>ADD</code> instruction doesn't support authentication.</p><h4 class=scroll-mt-20 id=adding-files-from-a-git-repository><a class="text-black dark:text-white no-underline hover:underline" href=#adding-files-from-a-git-repository>Adding files from a Git repository</a></h4><p>To use a Git repository as the source for <code>ADD</code>, you can reference the repository's HTTP or SSH address as the source. The repository is cloned to the specified destination in the image.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGh0dHBzOi8vZ2l0aHViLmNvbS91c2VyL3JlcG8uZ2l0IC9teWRpci8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> https://github.com/user/repo.git /mydir/</span></span></code></pre></div></div></div></div><p>You can use URL fragments to specify a specific branch, tag, commit, or subdirectory. For example, to add the <code>docs</code> directory of the <code>v0.14.1</code> tag of the <code>buildkit</code> repository:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIGdpdEBnaXRodWIuY29tOm1vYnkvYnVpbGRraXQuZ2l0I3YwLjE0LjE6ZG9jcyAvYnVpbGRraXQtZG9jcw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> git@github.com:moby/buildkit.git#v0.14.1:docs /buildkit-docs</span></span></code></pre></div></div></div></div><p>For more information about Git URL fragments, see <a class=link href=https://docs.docker.com/build/building/context/#url-fragments rel=noopener>URL fragments<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><p>When adding from a Git repository, the permissions bits for files are 644. If a file in the repository has the executable bit set, it will have permissions set to 755. Directories have permissions set to 755.</p><p>When using a Git repository as the source, the repository must be accessible from the build context. To add a repository via SSH, whether public or private, you must pass an SSH key for authentication. For example, given the following Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBREQgZ2l0QGdpdC5leGFtcGxlLmNvbTpmb28vYmFyLmdpdCAvYmFy', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> git@git.example.com:foo/bar.git /bar</span></span></code></pre></div></div></div></div><p>To build this Dockerfile, pass the <code>--ssh</code> flag to the <code>docker build</code> to mount the SSH agent socket to the build. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1zc2ggZGVmYXVsdCAu', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --ssh default . </span></span></code></pre></div></div></div></div><p>For more information about building with secrets, see <a class=link href=https://docs.docker.com/build/building/secrets/ rel=noopener>Build secrets<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=destination><a class="text-black dark:text-white no-underline hover:underline" href=#destination>Destination</a></h3><p>If the destination path begins with a forward slash, it's interpreted as an absolute path, and the source files are copied into the specified destination relative to the root of the current build stage.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjcmVhdGUgL2Ficy90ZXN0LnR4dApBREQgdGVzdC50eHQgL2Ficy8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># create /abs/test.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> test.txt /abs/</span></span></code></pre></div></div></div></div><p>Trailing slashes are significant. For example, <code>ADD test.txt /abs</code> creates a file at <code>/abs</code>, whereas <code>ADD test.txt /abs/</code> creates <code>/abs/test.txt</code>.</p><p>If the destination path doesn't begin with a leading slash, it's interpreted as relative to the working directory of the build container.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvdXNyL3NyYy9hcHAKIyBjcmVhdGUgL3Vzci9zcmMvYXBwL3JlbC90ZXN0LnR4dApBREQgdGVzdC50eHQgcmVsLw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /usr/src/app</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># create /usr/src/app/rel/test.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> test.txt rel/</span></span></code></pre></div></div></div></div><p>If destination doesn't exist, it's created, along with all missing directories in its path.</p><p>If the source is a file, and the destination doesn't end with a trailing slash, the source file will be written to the destination path as a file.</p><h3 class=scroll-mt-20 id=add---keep-git-dir><a class="text-black dark:text-white no-underline hover:underline" href=#add---keep-git-dir>ADD --keep-git-dir</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIFstLWtlZXAtZ2l0LWRpcj08Ym9vbGVhbj5dIDxzcmM+IC4uLiA8ZGlyPg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> <span class=o>[</span>--keep-git-dir<span class=o>=</span><boolean><span class=o>]</span> <src> ... <dir></span></span></code></pre></div></div></div></div><p>When <code><src></code> is the HTTP or SSH address of a remote Git repository, BuildKit adds the contents of the Git repository to the image excluding the <code>.git</code> directory by default.</p><p>The <code>--keep-git-dir=true</code> flag lets you preserve the <code>.git</code> directory.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBREQgLS1rZWVwLWdpdC1kaXI9dHJ1ZSBodHRwczovL2dpdGh1Yi5jb20vbW9ieS9idWlsZGtpdC5naXQjdjAuMTAuMSAvYnVpbGRraXQ=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --keep-git-dir<span class=o>=</span><span class=nb>true</span> https://github.com/moby/buildkit.git#v0.10.1 /buildkit</span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=add---checksum><a class="text-black dark:text-white no-underline hover:underline" href=#add---checksum>ADD --checksum</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIFstLWNoZWNrc3VtPTxoYXNoPl0gPHNyYz4gLi4uIDxkaXI+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> <span class=o>[</span>--checksum<span class=o>=</span><hash><span class=o>]</span> <src> ... <dir></span></span></code></pre></div></div></div></div><p>The <code>--checksum</code> flag lets you verify the checksum of a remote resource. The checksum is formatted as <code>sha256:<hash></code>. SHA-256 is the only supported hash algorithm.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QUREIC0tY2hlY2tzdW09c2hhMjU2OjI0NDU0ZjgzMGNkYjU3MWUyYzRhZDE1NDgxMTE5YzQzYjNjYWZkNDhkZDg2OWE5YjI5NDVkMTAzNmQxZGM2OGQgaHR0cHM6Ly9taXJyb3JzLmVkZ2Uua2VybmVsLm9yZy9wdWIvbGludXgva2VybmVsL0hpc3RvcmljL2xpbnV4LTAuMDEudGFyLmd6IC8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> --checksum<span class=o>=</span>sha256:24454f830cdb571e2c4ad15481119c43b3cafd48dd869a9b2945d1036d1dc68d https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz /</span></span></code></pre></div></div></div></div><p>The <code>--checksum</code> flag only supports HTTP(S) sources.</p><h3 class=scroll-mt-20 id=add---chown---chmod><a class="text-black dark:text-white no-underline hover:underline" href=#add---chown---chmod>ADD --chown --chmod</a></h3><p>See <a class=link href=#copy---chown---chmod><code>COPY --chown --chmod</code></a>.</p><h3 class=scroll-mt-20 id=add---link><a class="text-black dark:text-white no-underline hover:underline" href=#add---link>ADD --link</a></h3><p>See <a class=link href=#copy---link><code>COPY --link</code></a>.</p><h3 class=scroll-mt-20 id=add---exclude><a class="text-black dark:text-white no-underline hover:underline" href=#add---exclude>ADD --exclude</a></h3><p>See <a class=link href=#copy---exclude><code>COPY --exclude</code></a>.</p><h2 class=scroll-mt-20 id=copy><a class="text-black dark:text-white no-underline hover:underline" href=#copy>COPY</a></h2><p>COPY has two forms. The latter form is required for paths containing whitespace.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbT1BUSU9OU10gPHNyYz4gLi4uIDxkZXN0PgpDT1BZIFtPUFRJT05TXSBbIjxzcmM+IiwgLi4uICI8ZGVzdD4iXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <src> ... <dest><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> <span class=o>[</span>OPTIONS<span class=o>]</span> <span class=o>[</span><span class=s2>"<src>"</span>, ... <span class=s2>"<dest>"</span><span class=o>]</span></span></span></code></pre></div></div></div></div><p>The available <code>[OPTIONS]</code> are:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Option</th><th class=p-2>Minimum Dockerfile version</th></tr></thead><tbody><tr><td class=p-2><a class=link href=#copy---from><code>--from</code></a></td><td class=p-2></td></tr><tr><td class=p-2><a class=link href=#copy---chown---chmod><code>--chown</code></a></td><td class=p-2></td></tr><tr><td class=p-2><a class=link href=#copy---chown---chmod><code>--chmod</code></a></td><td class=p-2>1.2</td></tr><tr><td class=p-2><a class=link href=#copy---link><code>--link</code></a></td><td class=p-2>1.4</td></tr><tr><td class=p-2><a class=link href=#copy---parents><code>--parents</code></a></td><td class=p-2>1.7-labs</td></tr><tr><td class=p-2><a class=link href=#copy---exclude><code>--exclude</code></a></td><td class=p-2>1.7-labs</td></tr></tbody></table></div><p>The <code>COPY</code> instruction copies new files or directories from <code><src></code> and adds them to the filesystem of the image at the path <code><dest></code>. Files and directories can be copied from the build context, build stage, named context, or an image.</p><p>The <code>ADD</code> and <code>COPY</code> instructions are functionally similar, but serve slightly different purposes. Learn more about the <a class=link href=https://docs.docker.com/build/building/best-practices/#add-or-copy rel=noopener>differences between <code>ADD</code> and <code>COPY</code><span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=source-1><a class="text-black dark:text-white no-underline hover:underline" href=#source-1>Source</a></h3><p>You can specify multiple source files or directories with <code>COPY</code>. The last argument must always be the destination. For example, to copy two files, <code>file1.txt</code> and <code>file2.txt</code>, from the build context to <code>/usr/src/things/</code> in the build container:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBmaWxlMS50eHQgZmlsZTIudHh0IC91c3Ivc3JjL3RoaW5ncy8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> file1.txt file2.txt /usr/src/things/</span></span></code></pre></div></div></div></div><p>If you specify multiple source files, either directly or using a wildcard, then the destination must be a directory (must end with a slash <code>/</code>).</p><p><code>COPY</code> accepts a flag <code>--from=<name></code> that lets you specify the source location to be a build stage, context, or image. The following example copies files from a stage named <code>build</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBnb2xhbmcgQVMgYnVpbGQKV09SS0RJUiAvYXBwClJVTiAtLW1vdW50PXR5cGU9YmluZCx0YXJnZXQ9LiBnbyBidWlsZCAtbyAvbXlhcHAgLi9jbWQKCkNPUFkgLS1mcm9tPWJ1aWxkIC9teWFwcCAvdXNyL2Jpbi8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> golang AS build</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> /app</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>bind,target<span class=o>=</span>. go build -o /myapp ./cmd<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --from<span class=o>=</span>build /myapp /usr/bin/</span></span></code></pre></div></div></div></div><p>For more information about copying from named sources, see the <a class=link href=#copy---from><code>--from</code> flag</a>.</p><h4 class=scroll-mt-20 id=copying-from-the-build-context><a class="text-black dark:text-white no-underline hover:underline" href=#copying-from-the-build-context>Copying from the build context</a></h4><p>When copying source files from the build context, paths are interpreted as relative to the root of the context.</p><p>Specifying a source path with a leading slash or one that navigates outside the build context, such as <code>COPY ../something /something</code>, automatically removes any parent directory navigation (<code>../</code>). Trailing slashes in the source path are also disregarded, making <code>COPY something/ /something</code> equivalent to <code>COPY something /something</code>.</p><p>If the source is a directory, the contents of the directory are copied, including filesystem metadata. The directory itself isn't copied, only its contents. If it contains subdirectories, these are also copied, and merged with any existing directories at the destination. Any conflicts are resolved in favor of the content being added, on a file-by-file basis, except if you're trying to copy a directory onto an existing file, in which case an error is raised.</p><p>If the source is a file, the file and its metadata are copied to the destination. File permissions are preserved. If the source is a file and a directory with the same name exists at the destination, an error is raised.</p><p>If you pass a Dockerfile through stdin to the build (<code>docker build - < Dockerfile</code>), there is no build context. In this case, you can only use the <code>COPY</code> instruction to copy files from other stages, named contexts, or images, using the <a class=link href=#copy---from><code>--from</code> flag</a>. You can also pass a tar archive through stdin: (<code>docker build - < archive.tar</code>), the Dockerfile at the root of the archive and the rest of the archive will be used as the context of the build.</p><p>When using a Git repository as the build context, the permissions bits for copied files are 644. If a file in the repository has the executable bit set, it will have permissions set to 755. Directories have permissions set to 755.</p><h5 class=scroll-mt-20 id=pattern-matching-1><a class="text-black dark:text-white no-underline hover:underline" href=#pattern-matching-1>Pattern matching</a></h5><p>For local files, each <code><src></code> may contain wildcards and matching will be done using Go's <a class=link href=https://golang.org/pkg/path/filepath#Match rel=noopener>filepath.Match<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> rules.</p><p>For example, to add all files and directories in the root of the build context ending with <code>.png</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSAqLnBuZyAvZGVzdC8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> *.png /dest/</span></span></code></pre></div></div></div></div><p>In the following example, <code>?</code> is a single-character wildcard, matching e.g. <code>index.js</code> and <code>index.ts</code>.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBpbmRleC4/cyAvZGVzdC8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> index.?s /dest/</span></span></code></pre></div></div></div></div><p>When adding files or directories that contain special characters (such as <code>[</code> and <code>]</code>), you need to escape those paths following the Golang rules to prevent them from being treated as a matching pattern. For example, to add a file named <code>arr[0].txt</code>, use the following;</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBhcnJbW10wXS50eHQgL2Rlc3Qv', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> arr<span class=o>[[]</span>0<span class=o>]</span>.txt /dest/</span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=destination-1><a class="text-black dark:text-white no-underline hover:underline" href=#destination-1>Destination</a></h3><p>If the destination path begins with a forward slash, it's interpreted as an absolute path, and the source files are copied into the specified destination relative to the root of the current build stage.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBjcmVhdGUgL2Ficy90ZXN0LnR4dApDT1BZIHRlc3QudHh0IC9hYnMv', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># create /abs/test.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> test.txt /abs/</span></span></code></pre></div></div></div></div><p>Trailing slashes are significant. For example, <code>COPY test.txt /abs</code> creates a file at <code>/abs</code>, whereas <code>COPY test.txt /abs/</code> creates <code>/abs/test.txt</code>.</p><p>If the destination path doesn't begin with a leading slash, it's interpreted as relative to the working directory of the build container.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvdXNyL3NyYy9hcHAKIyBjcmVhdGUgL3Vzci9zcmMvYXBwL3JlbC90ZXN0LnR4dApDT1BZIHRlc3QudHh0IHJlbC8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /usr/src/app</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># create /usr/src/app/rel/test.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> test.txt rel/</span></span></code></pre></div></div></div></div><p>If destination doesn't exist, it's created, along with all missing directories in its path.</p><p>If the source is a file, and the destination doesn't end with a trailing slash, the source file will be written to the destination path as a file.</p><h3 class=scroll-mt-20 id=copy---from><a class="text-black dark:text-white no-underline hover:underline" href=#copy---from>COPY --from</a></h3><p>By default, the <code>COPY</code> instruction copies files from the build context. The <code>COPY --from</code> flag lets you copy files from an image, a build stage, or a named context instead.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1mcm9tPTxpbWFnZXxzdGFnZXxjb250ZXh0Pl0gPHNyYz4gLi4uIDxkZXN0Pg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--from<span class=o>=</span><image<span class=p>|</span>stage<span class=p>|</span>context><span class=o>]</span> <src> ... <dest></span></span></code></pre></div></div></div></div><p>To copy from a build stage in a <a class=link href=https://docs.docker.com/build/building/multi-stage/ rel=noopener>multi-stage build<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>, specify the name of the stage you want to copy from. You specify stage names using the <code>AS</code> keyword with the <code>FROM</code> instruction.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZSBBUyBidWlsZApDT1BZIC4gLgpSVU4gYXBrIGFkZCBjbGFuZwpSVU4gY2xhbmcgLW8gL2hlbGxvIGhlbGxvLmMKCkZST00gc2NyYXRjaApDT1BZIC0tZnJvbT1idWlsZCAvaGVsbG8gLw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine AS build</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> . .<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apk add clang<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> clang -o /hello hello.c<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --from<span class=o>=</span>build /hello /</span></span></code></pre></div></div></div></div><p>You can also copy files directly from named contexts (specified with <code>--build-context <name>=<source></code>) or images. The following example copies an <code>nginx.conf</code> file from the official Nginx image.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSAtLWZyb209bmdpbng6bGF0ZXN0IC9ldGMvbmdpbngvbmdpbnguY29uZiAvbmdpbnguY29uZg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> --from<span class=o>=</span>nginx:latest /etc/nginx/nginx.conf /nginx.conf</span></span></code></pre></div></div></div></div><p>The source path of <code>COPY --from</code> is always resolved from filesystem root of the image or stage that you specify.</p><h3 class=scroll-mt-20 id=copy---chown---chmod><a class="text-black dark:text-white no-underline hover:underline" href=#copy---chown---chmod>COPY --chown --chmod</a></h3><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Only octal notation is currently supported. Non-octal support is tracked in <a class=link href=https://github.com/moby/buildkit/issues/1951 rel=noopener>moby/buildkit#1951<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p></blockquote><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1jaG93bj08dXNlcj46PGdyb3VwPl0gWy0tY2htb2Q9PHBlcm1zPiAuLi5dIDxzcmM+IC4uLiA8ZGVzdD4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--chown<span class=o>=</span><user>:<group><span class=o>]</span> <span class=o>[</span>--chmod<span class=o>=</span><perms> ...<span class=o>]</span> <src> ... <dest></span></span></code></pre></div></div></div></div><p>The <code>--chown</code> and <code>--chmod</code> features are only supported on Dockerfiles used to build Linux containers, and doesn't work on Windows containers. Since user and group ownership concepts do not translate between Linux and Windows, the use of <code>/etc/passwd</code> and <code>/etc/group</code> for translating user and group names to IDs restricts this feature to only be viable for Linux OS-based containers.</p><p>All files and directories copied from the build context are created with a UID and GID of <code>0</code> unless the optional <code>--chown</code> flag specifies a given username, groupname, or UID/GID combination to request specific ownership of the copied content. The format of the <code>--chown</code> flag allows for either username and groupname strings or direct integer UID and GID in any combination. Providing a username without groupname or a UID without GID will use the same numeric UID as the GID. If a username or groupname is provided, the container's root filesystem <code>/etc/passwd</code> and <code>/etc/group</code> files will be used to perform the translation from name to integer UID or GID respectively. The following examples show valid definitions for the <code>--chown</code> flag:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSAtLWNob3duPTU1Om15Z3JvdXAgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249YmluIGZpbGVzKiAvc29tZWRpci8KQ09QWSAtLWNob3duPTEgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249MTA6MTEgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249bXl1c2VyOm15Z3JvdXAgLS1jaG1vZD02NDQgZmlsZXMqIC9zb21lZGlyLw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> --chown<span class=o>=</span>55:mygroup files* /somedir/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>bin files* /somedir/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span><span class=m>1</span> files* /somedir/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>10:11 files* /somedir/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>myuser:mygroup --chmod<span class=o>=</span><span class=m>644</span> files* /somedir/</span></span></code></pre></div></div></div></div><p>If the container root filesystem doesn't contain either <code>/etc/passwd</code> or <code>/etc/group</code> files and either user or group names are used in the <code>--chown</code> flag, the build will fail on the <code>COPY</code> operation. Using numeric IDs requires no lookup and does not depend on container root filesystem content.</p><p>With the Dockerfile syntax version 1.10.0 and later, the <code>--chmod</code> flag supports variable interpolation, which lets you define the permission bits using build arguments:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS4xMApGUk9NIGFscGluZQpXT1JLRElSIC9zcmMKQVJHIE1PREU9NDQwCkNPUFkgLS1jaG1vZD0kTU9ERSAuIC4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1.10</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> /src</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>MODE</span><span class=o>=</span><span class=m>440</span> </span></span><span class=line><span class=cl><span class=k>COPY</span> --chmod<span class=o>=</span><span class=nv>$MODE</span> . .</span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=copy---link><a class="text-black dark:text-white no-underline hover:underline" href=#copy---link>COPY --link</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1saW5rWz08Ym9vbGVhbj5dXSA8c3JjPiAuLi4gPGRlc3Q+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--link<span class=o>[=</span><boolean><span class=o>]]</span> <src> ... <dest></span></span></code></pre></div></div></div></div><p>Enabling this flag in <code>COPY</code> or <code>ADD</code> commands allows you to copy files with enhanced semantics where your files remain independent on their own layer and don't get invalidated when commands on previous layers are changed.</p><p>When <code>--link</code> is used your source files are copied into an empty destination directory. That directory is turned into a layer that is linked on top of your previous state.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpDT1BZIC0tbGluayAvZm9vIC9iYXI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --link /foo /bar</span></span></code></pre></div></div></div></div><p>Is equivalent of doing two builds:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBhbHBpbmU=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> alpine</span></span></span></code></pre></div></div></div></div><p>and</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBzY3JhdGNoCkNPUFkgL2ZvbyAvYmFy', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> /foo /bar</span></span></code></pre></div></div></div></div><p>and merging all the layers of both images together.</p><h4 class=scroll-mt-20 id=benefits-of-using---link><a class="text-black dark:text-white no-underline hover:underline" href=#benefits-of-using---link>Benefits of using <code>--link</code></a></h4><p>Use <code>--link</code> to reuse already built layers in subsequent builds with <code>--cache-from</code> even if the previous layers have changed. This is especially important for multi-stage builds where a <code>COPY --from</code> statement would previously get invalidated if any previous commands in the same stage changed, causing the need to rebuild the intermediate stages again. With <code>--link</code> the layer the previous build generated is reused and merged on top of the new layers. This also means you can easily rebase your images when the base images receive updates, without having to execute the whole build again. In backends that support it, BuildKit can do this rebase action without the need to push or pull any layers between the client and the registry. BuildKit will detect this case and only create new image manifest that contains the new layers and old layers in correct order.</p><p>The same behavior where BuildKit can avoid pulling down the base image can also happen when using <code>--link</code> and no other commands that would require access to the files in the base image. In that case BuildKit will only build the layers for the <code>COPY</code> commands and push them to the registry directly on top of the layers of the base image.</p><h4 class=scroll-mt-20 id=incompatibilities-with---linkfalse><a class="text-black dark:text-white no-underline hover:underline" href=#incompatibilities-with---linkfalse>Incompatibilities with <code>--link=false</code></a></h4><p>When using <code>--link</code> the <code>COPY/ADD</code> commands are not allowed to read any files from the previous state. This means that if in previous state the destination directory was a path that contained a symlink, <code>COPY/ADD</code> can not follow it. In the final image the destination path created with <code>--link</code> will always be a path containing only directories.</p><p>If you don't rely on the behavior of following symlinks in the destination path, using <code>--link</code> is always recommended. The performance of <code>--link</code> is equivalent or better than the default behavior and, it creates much better conditions for cache reuse.</p><h3 class=scroll-mt-20 id=copy---parents><a class="text-black dark:text-white no-underline hover:underline" href=#copy---parents>COPY --parents</a></h3><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Not yet available in stable syntax, use <a class=link href=#syntax><code>docker/dockerfile:1.7-labs</code></a> version.</p></blockquote><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1wYXJlbnRzWz08Ym9vbGVhbj5dXSA8c3JjPiAuLi4gPGRlc3Q+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--parents<span class=o>[=</span><boolean><span class=o>]]</span> <src> ... <dest></span></span></code></pre></div></div></div></div><p>The <code>--parents</code> flag preserves parent directories for <code>src</code> entries. This flag defaults to <code>false</code>.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gc2NyYXRjaAoKQ09QWSAuL3gvYS50eHQgLi95L2EudHh0IC9ub19wYXJlbnRzLwpDT1BZIC0tcGFyZW50cyAuL3gvYS50eHQgLi95L2EudHh0IC9wYXJlbnRzLwoKIyAvbm9fcGFyZW50cy9hLnR4dAojIC9wYXJlbnRzL3gvYS50eHQKIyAvcGFyZW50cy95L2EudHh0', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> ./x/a.txt ./y/a.txt /no_parents/<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --parents ./x/a.txt ./y/a.txt /parents/<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /no_parents/a.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/x/a.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/y/a.txt</span></span></span></code></pre></div></div></div></div><p>This behavior is similar to the <a class=link href=https://www.man7.org/linux/man-pages/man1/cp.1.html rel=noopener>Linux <code>cp</code> utility's<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> <code>--parents</code> or <a class=link href=https://man7.org/linux/man-pages/man1/rsync.1.html rel=noopener><code>rsync</code><span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> <code>--relative</code> flag.</p><p>As with Rsync, it is possible to limit which parent directories are preserved by inserting a dot and a slash (<code>./</code>) into the source path. If such point exists, only parent directories after it will be preserved. This may be especially useful copies between stages with <code>--from</code> where the source paths need to be absolute.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gc2NyYXRjaAoKQ09QWSAtLXBhcmVudHMgLi94Ly4veS8qLnR4dCAvcGFyZW50cy8KCiMgQnVpbGQgY29udGV4dDoKIyAuL3gveS9hLnR4dAojIC4veC95L2IudHh0CiMKIyBPdXRwdXQ6CiMgL3BhcmVudHMveS9hLnR4dAojIC9wYXJlbnRzL3kvYi50eHQ=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --parents ./x/./y/*.txt /parents/<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Build context:</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ./x/y/a.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ./x/y/b.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c>#</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Output:</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/y/a.txt</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/y/b.txt</span></span></span></code></pre></div></div></div></div><p>Note that, without the <code>--parents</code> flag specified, any filename collision will fail the Linux <code>cp</code> operation with an explicit error message (<code>cp: will not overwrite just-created './x/a.txt' with './y/a.txt'</code>), where the Buildkit will silently overwrite the target file at the destination.</p><p>While it is possible to preserve the directory structure for <code>COPY</code> instructions consisting of only one <code>src</code> entry, usually it is more beneficial to keep the layer count in the resulting image as low as possible. Therefore, with the <code>--parents</code> flag, the Buildkit is capable of packing multiple <code>COPY</code> instructions together, keeping the directory structure intact.</p><h3 class=scroll-mt-20 id=copy---exclude><a class="text-black dark:text-white no-underline hover:underline" href=#copy---exclude>COPY --exclude</a></h3><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>Not yet available in stable syntax, use <a class=link href=#syntax><code>docker/dockerfile:1.7-labs</code></a> version.</p></blockquote><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1leGNsdWRlPTxwYXRoPiAuLi5dIDxzcmM+IC4uLiA8ZGVzdD4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--exclude<span class=o>=</span><path> ...<span class=o>]</span> <src> ... <dest></span></span></code></pre></div></div></div></div><p>The <code>--exclude</code> flag lets you specify a path expression for files to be excluded.</p><p>The path expression follows the same format as <code><src></code>, supporting wildcards and matching using Go's <a class=link href=https://golang.org/pkg/path/filepath#Match rel=noopener>filepath.Match<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> rules. For example, to add all files starting with "hom", excluding files with a <code>.txt</code> extension:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gc2NyYXRjaAoKQ09QWSAtLWV4Y2x1ZGU9Ki50eHQgaG9tKiAvbXlkaXIv', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --exclude<span class=o>=</span>*.txt hom* /mydir/</span></span></code></pre></div></div></div></div><p>You can specify the <code>--exclude</code> option multiple times for a <code>COPY</code> instruction. Multiple <code>--excludes</code> are files matching its patterns not to be copied, even if the files paths match the pattern specified in <code><src></code>. To add all files starting with "hom", excluding files with either <code>.txt</code> or <code>.md</code> extensions:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gc2NyYXRjaAoKQ09QWSAtLWV4Y2x1ZGU9Ki50eHQgLS1leGNsdWRlPSoubWQgaG9tKiAvbXlkaXIv', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --exclude<span class=o>=</span>*.txt --exclude<span class=o>=</span>*.md hom* /mydir/</span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=entrypoint><a class="text-black dark:text-white no-underline hover:underline" href=#entrypoint>ENTRYPOINT</a></h2><p>An <code>ENTRYPOINT</code> allows you to configure a container that will run as an executable.</p><p><code>ENTRYPOINT</code> has two possible forms:</p><ul><li><p>The exec form, which is the preferred form:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBbImV4ZWN1dGFibGUiLCAicGFyYW0xIiwgInBhcmFtMiJd', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>"executable"</span><span class=p>,</span> <span class=s2>"param1"</span><span class=p>,</span> <span class=s2>"param2"</span><span class=p>]</span></span></span></code></pre></div></div></div></div></li><li><p>The shell form:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBjb21tYW5kIHBhcmFtMSBwYXJhbTI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=nb>command</span> param1 param2</span></span></code></pre></div></div></div></div></li></ul><p>For more information about the different forms, see <a class=link href=#shell-and-exec-form>Shell and exec form</a>.</p><p>The following command starts a container from the <code>nginx</code> with its default content, listening on port 80:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pIC10IC0tcm0gLXAgODA6ODAgbmdpbng=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -i -t --rm -p 80:80 nginx </span></span></code></pre></div></div></div></div><p>Command line arguments to <code>docker run <image></code> will be appended after all elements in an exec form <code>ENTRYPOINT</code>, and will override all elements specified using <code>CMD</code>.</p><p>This allows arguments to be passed to the entry point, i.e., <code>docker run <image> -d</code> will pass the <code>-d</code> argument to the entry point. You can override the <code>ENTRYPOINT</code> instruction using the <code>docker run --entrypoint</code> flag.</p><p>The shell form of <code>ENTRYPOINT</code> prevents any <code>CMD</code> command line arguments from being used. It also starts your <code>ENTRYPOINT</code> as a subcommand of <code>/bin/sh -c</code>, which does not pass signals. This means that the executable will not be the container's <code>PID 1</code>, and will not receive Unix signals. In this case, your executable doesn't receive a <code>SIGTERM</code> from <code>docker stop <container></code>.</p><p>Only the last <code>ENTRYPOINT</code> instruction in the Dockerfile will have an effect.</p><h3 class=scroll-mt-20 id=exec-form-entrypoint-example><a class="text-black dark:text-white no-underline hover:underline" href=#exec-form-entrypoint-example>Exec form ENTRYPOINT example</a></h3><p>You can use the exec form of <code>ENTRYPOINT</code> to set fairly stable default commands and arguments and then use either form of <code>CMD</code> to set additional defaults that are more likely to be changed.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCBbInRvcCIsICItYiJdCkNNRCBbIi1jIl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>"top"</span><span class=p>,</span> <span class=s2>"-b"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> <span class=p>[</span><span class=s2>"-c"</span><span class=p>]</span></span></span></code></pre></div></div></div></div><p>When you run the container, you can see that <code>top</code> is the only process:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLXJtIC0tbmFtZSB0ZXN0ICB0b3AgLUgKCnRvcCAtIDA4OjI1OjAwIHVwICA3OjI3LCAgMCB1c2VycywgIGxvYWQgYXZlcmFnZTogMC4wMCwgMC4wMSwgMC4wNQpUaHJlYWRzOiAgIDEgdG90YWwsICAgMSBydW5uaW5nLCAgIDAgc2xlZXBpbmcsICAgMCBzdG9wcGVkLCAgIDAgem9tYmllCiVDcHUocyk6ICAwLjEgdXMsICAwLjEgc3ksICAwLjAgbmksIDk5LjcgaWQsICAwLjAgd2EsICAwLjAgaGksICAwLjAgc2ksICAwLjAgc3QKS2lCIE1lbTogICAyMDU2NjY4IHRvdGFsLCAgMTYxNjgzMiB1c2VkLCAgIDQzOTgzNiBmcmVlLCAgICA5OTM1MiBidWZmZXJzCktpQiBTd2FwOiAgMTQ0MTg0MCB0b3RhbCwgICAgICAgIDAgdXNlZCwgIDE0NDE4NDAgZnJlZS4gIDEzMjQ0NDAgY2FjaGVkIE1lbQoKICBQSUQgVVNFUiAgICAgIFBSICBOSSAgICBWSVJUICAgIFJFUyAgICBTSFIgUyAlQ1BVICVNRU0gICAgIFRJTUUrIENPTU1BTkQKICAgIDEgcm9vdCAgICAgIDIwICAgMCAgIDE5NzQ0ICAgMjMzNiAgIDIwODAgUiAgMC4wICAwLjEgICAwOjAwLjA0IHRvcA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --rm --name <span class=nb>test</span> top -H </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>top - 08:25:00 up 7:27, 0 users, load average: 0.00, 0.01, 0.05 </span></span></span><span class=line><span class=cl><span class=go>Threads: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie </span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>%</span>Cpu<span class=o>(</span>s<span class=o>)</span>: 0.1 us, 0.1 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st </span></span><span class=line><span class=cl><span class=go>KiB Mem: 2056668 total, 1616832 used, 439836 free, 99352 buffers </span></span></span><span class=line><span class=cl><span class=go>KiB Swap: 1441840 total, 0 used, 1441840 free. 1324440 cached Mem </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND </span></span></span><span class=line><span class=cl><span class=go> 1 root 20 0 19744 2336 2080 R 0.0 0.1 0:00.04 top </span></span></span></code></pre></div></div></div></div><p>To examine the result further, you can use <code>docker exec</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyBhdXgKClVTRVIgICAgICAgUElEICVDUFUgJU1FTSAgICBWU1ogICBSU1MgVFRZICAgICAgU1RBVCBTVEFSVCAgIFRJTUUgQ09NTUFORApyb290ICAgICAgICAgMSAgMi42ICAwLjEgIDE5NzUyICAyMzUyID8gICAgICAgIFNzKyAgMDg6MjQgICAwOjAwIHRvcCAtYiAtSApyb290ICAgICAgICAgNyAgMC4wICAwLjEgIDE1NTcyICAyMTY0ID8gICAgICAgIFIrICAgMDg6MjUgICAwOjAwIHBzIGF1eA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps aux </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND </span></span></span><span class=line><span class=cl><span class=go>root 1 2.6 0.1 19752 2352 ? Ss+ 08:24 0:00 top -b -H </span></span></span><span class=line><span class=cl><span class=go>root 7 0.0 0.1 15572 2164 ? R+ 08:25 0:00 ps aux </span></span></span></code></pre></div></div></div></div><p>And you can gracefully request <code>top</code> to shut down using <code>docker stop test</code>.</p><p>The following Dockerfile shows using the <code>ENTRYPOINT</code> to run Apache in the foreground (i.e., as <code>PID 1</code>):</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBkZWJpYW46c3RhYmxlClJVTiBhcHQtZ2V0IHVwZGF0ZSAmJiBhcHQtZ2V0IGluc3RhbGwgLXkgLS1mb3JjZS15ZXMgYXBhY2hlMgpFWFBPU0UgODAgNDQzClZPTFVNRSBbIi92YXIvd3d3IiwgIi92YXIvbG9nL2FwYWNoZTIiLCAiL2V0Yy9hcGFjaGUyIl0KRU5UUllQT0lOVCBbIi91c3Ivc2Jpbi9hcGFjaGUyY3RsIiwgIi1EIiwgIkZPUkVHUk9VTkQiXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> debian:stable</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apt-get update <span class=o>&&</span> apt-get install -y --force-yes apache2<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>EXPOSE</span><span class=s> 80 443</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>VOLUME</span> <span class=p>[</span><span class=s2>"/var/www"</span><span class=p>,</span> <span class=s2>"/var/log/apache2"</span><span class=p>,</span> <span class=s2>"/etc/apache2"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>"/usr/sbin/apache2ctl"</span><span class=p>,</span> <span class=s2>"-D"</span><span class=p>,</span> <span class=s2>"FOREGROUND"</span><span class=p>]</span></span></span></code></pre></div></div></div></div><p>If you need to write a starter script for a single executable, you can ensure that the final executable receives the Unix signals by using <code>exec</code> and <code>gosu</code> commands:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyEvdXNyL2Jpbi9lbnYgYmFzaApzZXQgLWUKCmlmIFsgIiQxIiA9ICdwb3N0Z3JlcycgXTsgdGhlbgogICAgY2hvd24gLVIgcG9zdGdyZXMgIiRQR0RBVEEiCgogICAgaWYgWyAteiAiJChscyAtQSAiJFBHREFUQSIpIiBdOyB0aGVuCiAgICAgICAgZ29zdSBwb3N0Z3JlcyBpbml0ZGIKICAgIGZpCgogICAgZXhlYyBnb3N1IHBvc3RncmVzICIkQCIKZmkKCmV4ZWMgIiRAIg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=cp>#!/usr/bin/env bash </span></span></span><span class=line><span class=cl><span class=cp></span><span class=nb>set</span> -e </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=k>if</span> <span class=o>[</span> <span class=s2>"</span><span class=nv>$1</span><span class=s2>"</span> <span class=o>=</span> <span class=s1>'postgres'</span> <span class=o>]</span><span class=p>;</span> <span class=k>then</span> </span></span><span class=line><span class=cl> chown -R postgres <span class=s2>"</span><span class=nv>$PGDATA</span><span class=s2>"</span> </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl> <span class=k>if</span> <span class=o>[</span> -z <span class=s2>"</span><span class=k>$(</span>ls -A <span class=s2>"</span><span class=nv>$PGDATA</span><span class=s2>"</span><span class=k>)</span><span class=s2>"</span> <span class=o>]</span><span class=p>;</span> <span class=k>then</span> </span></span><span class=line><span class=cl> gosu postgres initdb </span></span><span class=line><span class=cl> <span class=k>fi</span> </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl> <span class=nb>exec</span> gosu postgres <span class=s2>"</span><span class=nv>$@</span><span class=s2>"</span> </span></span><span class=line><span class=cl><span class=k>fi</span> </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=nb>exec</span> <span class=s2>"</span><span class=nv>$@</span><span class=s2>"</span></span></span></code></pre></div></div></div></div><p>Lastly, if you need to do some extra cleanup (or communicate with other containers) on shutdown, or are co-ordinating more than one executable, you may need to ensure that the <code>ENTRYPOINT</code> script receives the Unix signals, passes them on, and then does some more work:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyEvYmluL3NoCiMgTm90ZTogSSd2ZSB3cml0dGVuIHRoaXMgdXNpbmcgc2ggc28gaXQgd29ya3MgaW4gdGhlIGJ1c3lib3ggY29udGFpbmVyIHRvbwoKIyBVU0UgdGhlIHRyYXAgaWYgeW91IG5lZWQgdG8gYWxzbyBkbyBtYW51YWwgY2xlYW51cCBhZnRlciB0aGUgc2VydmljZSBpcyBzdG9wcGVkLAojICAgICBvciBuZWVkIHRvIHN0YXJ0IG11bHRpcGxlIHNlcnZpY2VzIGluIHRoZSBvbmUgY29udGFpbmVyCnRyYXAgImVjaG8gVFJBUGVkIHNpZ25hbCIgSFVQIElOVCBRVUlUIFRFUk0KCiMgc3RhcnQgc2VydmljZSBpbiBiYWNrZ3JvdW5kIGhlcmUKL3Vzci9zYmluL2FwYWNoZWN0bCBzdGFydAoKZWNobyAiW2hpdCBlbnRlciBrZXkgdG8gZXhpdF0gb3IgcnVuICdkb2NrZXIgc3RvcCA8Y29udGFpbmVyPiciCnJlYWQKCiMgc3RvcCBzZXJ2aWNlIGFuZCBjbGVhbiB1cCBoZXJlCmVjaG8gInN0b3BwaW5nIGFwYWNoZSIKL3Vzci9zYmluL2FwYWNoZWN0bCBzdG9wCgplY2hvICJleGl0ZWQgJDAi', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=cp>#!/bin/sh </span></span></span><span class=line><span class=cl><span class=cp></span><span class=c1># Note: I've written this using sh so it works in the busybox container too</span> </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=c1># USE the trap if you need to also do manual cleanup after the service is stopped,</span> </span></span><span class=line><span class=cl><span class=c1># or need to start multiple services in the one container</span> </span></span><span class=line><span class=cl><span class=nb>trap</span> <span class=s2>"echo TRAPed signal"</span> HUP INT QUIT TERM </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=c1># start service in background here</span> </span></span><span class=line><span class=cl>/usr/sbin/apachectl start </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>"[hit enter key to exit] or run 'docker stop <container>'"</span> </span></span><span class=line><span class=cl><span class=nb>read</span> </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=c1># stop service and clean up here</span> </span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>"stopping apache"</span> </span></span><span class=line><span class=cl>/usr/sbin/apachectl stop </span></span><span class=line><span class=cl> </span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>"exited </span><span class=nv>$0</span><span class=s2>"</span></span></span></code></pre></div></div></div></div><p>If you run this image with <code>docker run -it --rm -p 80:80 --name test apache</code>, you can then examine the container's processes with <code>docker exec</code>, or <code>docker top</code>, and then ask the script to stop Apache:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyBhdXgKClVTRVIgICAgICAgUElEICVDUFUgJU1FTSAgICBWU1ogICBSU1MgVFRZICAgICAgU1RBVCBTVEFSVCAgIFRJTUUgQ09NTUFORApyb290ICAgICAgICAgMSAgMC4xICAwLjAgICA0NDQ4ICAgNjkyID8gICAgICAgIFNzKyAgMDA6NDIgICAwOjAwIC9iaW4vc2ggL3J1bi5zaCAxMjMgY21kIGNtZDIKcm9vdCAgICAgICAgMTkgIDAuMCAgMC4yICA3MTMwNCAgNDQ0MCA/ICAgICAgICBTcyAgIDAwOjQyICAgMDowMCAvdXNyL3NiaW4vYXBhY2hlMiAtayBzdGFydAp3d3ctZGF0YSAgICAyMCAgMC4yICAwLjIgMzYwNDY4ICA2MDA0ID8gICAgICAgIFNsICAgMDA6NDIgICAwOjAwIC91c3Ivc2Jpbi9hcGFjaGUyIC1rIHN0YXJ0Cnd3dy1kYXRhICAgIDIxICAwLjIgIDAuMiAzNjA0NjggIDYwMDAgPyAgICAgICAgU2wgICAwMDo0MiAgIDA6MDAgL3Vzci9zYmluL2FwYWNoZTIgLWsgc3RhcnQKcm9vdCAgICAgICAgODEgIDAuMCAgMC4xICAxNTU3MiAgMjE0MCA/ICAgICAgICBSKyAgIDAwOjQ0ICAgMDowMCBwcyBhdXgKCiQgZG9ja2VyIHRvcCB0ZXN0CgpQSUQgICAgICAgICAgICAgICAgIFVTRVIgICAgICAgICAgICAgICAgQ09NTUFORAoxMDAzNSAgICAgICAgICAgICAgIHJvb3QgICAgICAgICAgICAgICAge3J1bi5zaH0gL2Jpbi9zaCAvcnVuLnNoIDEyMyBjbWQgY21kMgoxMDA1NCAgICAgICAgICAgICAgIHJvb3QgICAgICAgICAgICAgICAgL3Vzci9zYmluL2FwYWNoZTIgLWsgc3RhcnQKMTAwNTUgICAgICAgICAgICAgICAzMyAgICAgICAgICAgICAgICAgIC91c3Ivc2Jpbi9hcGFjaGUyIC1rIHN0YXJ0CjEwMDU2ICAgICAgICAgICAgICAgMzMgICAgICAgICAgICAgICAgICAvdXNyL3NiaW4vYXBhY2hlMiAtayBzdGFydAoKJCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAwLjI3cwp1c2VyCTBtIDAuMDNzCnN5cwkwbSAwLjAzcw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps aux </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND </span></span></span><span class=line><span class=cl><span class=go>root 1 0.1 0.0 4448 692 ? Ss+ 00:42 0:00 /bin/sh /run.sh 123 cmd cmd2 </span></span></span><span class=line><span class=cl><span class=go>root 19 0.0 0.2 71304 4440 ? Ss 00:42 0:00 /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go>www-data 20 0.2 0.2 360468 6004 ? Sl 00:42 0:00 /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go>www-data 21 0.2 0.2 360468 6000 ? Sl 00:42 0:00 /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go>root 81 0.0 0.1 15572 2140 ? R+ 00:44 0:00 ps aux </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> docker top <span class=nb>test</span> </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>PID USER COMMAND </span></span></span><span class=line><span class=cl><span class=go>10035 root {run.sh} /bin/sh /run.sh 123 cmd cmd2 </span></span></span><span class=line><span class=cl><span class=go>10054 root /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go>10055 33 /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go>10056 33 /usr/sbin/apache2 -k start </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span> </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test </span></span></span><span class=line><span class=cl><span class=go>real 0m 0.27s </span></span></span><span class=line><span class=cl><span class=go>user 0m 0.03s </span></span></span><span class=line><span class=cl><span class=go>sys 0m 0.03s </span></span></span></code></pre></div></div></div></div><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>You can override the <code>ENTRYPOINT</code> setting using <code>--entrypoint</code>, but this can only set the binary to exec (no <code>sh -c</code> will be used).</p></blockquote><h3 class=scroll-mt-20 id=shell-form-entrypoint-example><a class="text-black dark:text-white no-underline hover:underline" href=#shell-form-entrypoint-example>Shell form ENTRYPOINT example</a></h3><p>You can specify a plain string for the <code>ENTRYPOINT</code> and it will execute in <code>/bin/sh -c</code>. This form will use shell processing to substitute shell environment variables, and will ignore any <code>CMD</code> or <code>docker run</code> command line arguments. To ensure that <code>docker stop</code> will signal any long running <code>ENTRYPOINT</code> executable correctly, you need to remember to start it with <code>exec</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCBleGVjIHRvcCAtYg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=nb>exec</span> top -b</span></span></code></pre></div></div></div></div><p>When you run this image, you'll see the single <code>PID 1</code> process:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLXJtIC0tbmFtZSB0ZXN0IHRvcAoKTWVtOiAxNzA0NTIwSyB1c2VkLCAzNTIxNDhLIGZyZWUsIDBLIHNocmQsIDBLIGJ1ZmYsIDE0MDM2ODEyMTE2Nzg3M0sgY2FjaGVkCkNQVTogICA1JSB1c3IgICAwJSBzeXMgICAwJSBuaWMgIDk0JSBpZGxlICAgMCUgaW8gICAwJSBpcnEgICAwJSBzaXJxCkxvYWQgYXZlcmFnZTogMC4wOCAwLjAzIDAuMDUgMi85OCA2CiAgUElEICBQUElEIFVTRVIgICAgIFNUQVQgICBWU1ogJVZTWiAlQ1BVIENPTU1BTkQKICAgIDEgICAgIDAgcm9vdCAgICAgUiAgICAgMzE2NCAgIDAlICAgMCUgdG9wIC1i', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --rm --name <span class=nb>test</span> top </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Mem: 1704520K used, 352148K free, 0K shrd, 0K buff, 140368121167873K cached </span></span></span><span class=line><span class=cl><span class=go>CPU: 5% usr 0% sys 0% nic 94% idle 0% io 0% irq 0% sirq </span></span></span><span class=line><span class=cl><span class=go>Load average: 0.08 0.03 0.05 2/98 6 </span></span></span><span class=line><span class=cl><span class=go> PID PPID USER STAT VSZ %VSZ %CPU COMMAND </span></span></span><span class=line><span class=cl><span class=go> 1 0 root R 3164 0% 0% top -b </span></span></span></code></pre></div></div></div></div><p>Which exits cleanly on <code>docker stop</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAwLjIwcwp1c2VyCTBtIDAuMDJzCnN5cwkwbSAwLjA0cw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span> </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test </span></span></span><span class=line><span class=cl><span class=go>real 0m 0.20s </span></span></span><span class=line><span class=cl><span class=go>user 0m 0.02s </span></span></span><span class=line><span class=cl><span class=go>sys 0m 0.04s </span></span></span></code></pre></div></div></div></div><p>If you forget to add <code>exec</code> to the beginning of your <code>ENTRYPOINT</code>:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCB0b3AgLWIKQ01EIC0tIC0taWdub3JlZC1wYXJhbTE=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> top -b<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> -- --ignored-param1</span></span></code></pre></div></div></div></div><p>You can then run it (giving it a name for the next step):</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLW5hbWUgdGVzdCB0b3AgLS1pZ25vcmVkLXBhcmFtMgoKdG9wIC0gMTM6NTg6MjQgdXAgMTcgbWluLCAgMCB1c2VycywgIGxvYWQgYXZlcmFnZTogMC4wMCwgMC4wMCwgMC4wMApUYXNrczogICAyIHRvdGFsLCAgIDEgcnVubmluZywgICAxIHNsZWVwaW5nLCAgIDAgc3RvcHBlZCwgICAwIHpvbWJpZQolQ3B1KHMpOiAxNi43IHVzLCAzMy4zIHN5LCAgMC4wIG5pLCA1MC4wIGlkLCAgMC4wIHdhLCAgMC4wIGhpLCAgMC4wIHNpLCAgMC4wIHN0Ck1pQiBNZW0gOiAgIDE5OTAuOCB0b3RhbCwgICAxMzU0LjYgZnJlZSwgICAgMjMxLjQgdXNlZCwgICAgNDA0LjcgYnVmZi9jYWNoZQpNaUIgU3dhcDogICAxMDI0LjAgdG90YWwsICAgMTAyNC4wIGZyZWUsICAgICAgMC4wIHVzZWQuICAgMTYzOS44IGF2YWlsIE1lbQoKICBQSUQgVVNFUiAgICAgIFBSICBOSSAgICBWSVJUICAgIFJFUyAgICBTSFIgUyAgJUNQVSAgJU1FTSAgICAgVElNRSsgQ09NTUFORAogICAgMSByb290ICAgICAgMjAgICAwICAgIDI2MTIgICAgNjA0ICAgIDUzNiBTICAgMC4wICAgMC4wICAgMDowMC4wMiBzaAogICAgNiByb290ICAgICAgMjAgICAwICAgIDU5NTYgICAzMTg4ICAgMjc2OCBSICAgMC4wICAgMC4yICAgMDowMC4wMCB0b3A=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --name <span class=nb>test</span> top --ignored-param2 </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>top - 13:58:24 up 17 min, 0 users, load average: 0.00, 0.00, 0.00 </span></span></span><span class=line><span class=cl><span class=go>Tasks: 2 total, 1 running, 1 sleeping, 0 stopped, 0 zombie </span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>%</span>Cpu<span class=o>(</span>s<span class=o>)</span>: 16.7 us, 33.3 sy, 0.0 ni, 50.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st </span></span><span class=line><span class=cl><span class=go>MiB Mem : 1990.8 total, 1354.6 free, 231.4 used, 404.7 buff/cache </span></span></span><span class=line><span class=cl><span class=go>MiB Swap: 1024.0 total, 1024.0 free, 0.0 used. 1639.8 avail Mem </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND </span></span></span><span class=line><span class=cl><span class=go> 1 root 20 0 2612 604 536 S 0.0 0.0 0:00.02 sh </span></span></span><span class=line><span class=cl><span class=go> 6 root 20 0 5956 3188 2768 R 0.0 0.2 0:00.00 top </span></span></span></code></pre></div></div></div></div><p>You can see from the output of <code>top</code> that the specified <code>ENTRYPOINT</code> is not <code>PID 1</code>.</p><p>If you then run <code>docker stop test</code>, the container will not exit cleanly - the <code>stop</code> command will be forced to send a <code>SIGKILL</code> after the timeout:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyB3YXV4CgpVU0VSICAgICAgIFBJRCAlQ1BVICVNRU0gICAgVlNaICAgUlNTIFRUWSAgICAgIFNUQVQgU1RBUlQgICBUSU1FIENPTU1BTkQKcm9vdCAgICAgICAgIDEgIDAuNCAgMC4wICAgMjYxMiAgIDYwNCBwdHMvMCAgICBTcysgIDEzOjU4ICAgMDowMCAvYmluL3NoIC1jIHRvcCAtYiAtLWlnbm9yZWQtcGFyYW0yCnJvb3QgICAgICAgICA2ICAwLjAgIDAuMSAgIDU5NTYgIDMxODggcHRzLzAgICAgUysgICAxMzo1OCAgIDA6MDAgdG9wIC1iCnJvb3QgICAgICAgICA3ICAwLjAgIDAuMSAgIDU4ODQgIDI4MTYgcHRzLzEgICAgUnMrICAxMzo1OCAgIDA6MDAgcHMgd2F1eAoKJCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAxMC4xOXMKdXNlcgkwbSAwLjA0cwpzeXMJMG0gMC4wM3M=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps waux </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND </span></span></span><span class=line><span class=cl><span class=go>root 1 0.4 0.0 2612 604 pts/0 Ss+ 13:58 0:00 /bin/sh -c top -b --ignored-param2 </span></span></span><span class=line><span class=cl><span class=go>root 6 0.0 0.1 5956 3188 pts/0 S+ 13:58 0:00 top -b </span></span></span><span class=line><span class=cl><span class=go>root 7 0.0 0.1 5884 2816 pts/1 Rs+ 13:58 0:00 ps waux </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span> </span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test </span></span></span><span class=line><span class=cl><span class=go>real 0m 10.19s </span></span></span><span class=line><span class=cl><span class=go>user 0m 0.04s </span></span></span><span class=line><span class=cl><span class=go>sys 0m 0.03s </span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=understand-how-cmd-and-entrypoint-interact><a class="text-black dark:text-white no-underline hover:underline" href=#understand-how-cmd-and-entrypoint-interact>Understand how CMD and ENTRYPOINT interact</a></h3><p>Both <code>CMD</code> and <code>ENTRYPOINT</code> instructions define what command gets executed when running a container. There are few rules that describe their co-operation.</p><ol><li><p>Dockerfile should specify at least one of <code>CMD</code> or <code>ENTRYPOINT</code> commands.</p></li><li><p><code>ENTRYPOINT</code> should be defined when using the container as an executable.</p></li><li><p><code>CMD</code> should be used as a way of defining default arguments for an <code>ENTRYPOINT</code> command or for executing an ad-hoc command in a container.</p></li><li><p><code>CMD</code> will be overridden when running the container with alternative arguments.</p></li></ol><p>The table below shows what command is executed for different <code>ENTRYPOINT</code> / <code>CMD</code> combinations:</p><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2 style=text-align:left></th><th class=p-2 style=text-align:left>No ENTRYPOINT</th><th class=p-2 style=text-align:left>ENTRYPOINT exec_entry p1_entry</th><th class=p-2 style=text-align:left>ENTRYPOINT ["exec_entry", "p1_entry"]</th></tr></thead><tbody><tr><td class=p-2 style=text-align:left><strong>No CMD</strong></td><td class=p-2 style=text-align:left>error, not allowed</td><td class=p-2 style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td class=p-2 style=text-align:left>exec_entry p1_entry</td></tr><tr><td class=p-2 style=text-align:left><strong>CMD ["exec_cmd", "p1_cmd"]</strong></td><td class=p-2 style=text-align:left>exec_cmd p1_cmd</td><td class=p-2 style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td class=p-2 style=text-align:left>exec_entry p1_entry exec_cmd p1_cmd</td></tr><tr><td class=p-2 style=text-align:left><strong>CMD exec_cmd p1_cmd</strong></td><td class=p-2 style=text-align:left>/bin/sh -c exec_cmd p1_cmd</td><td class=p-2 style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td class=p-2 style=text-align:left>exec_entry p1_entry /bin/sh -c exec_cmd p1_cmd</td></tr></tbody></table></div><blockquote class="px-4 border-l-4 border-blue-light dark:border-blue-dark"><p class="flex gap-2 items-center text-blue-light dark:text-blue-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M483.18-280q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63zm-3.2-314q14.02.0 23.52-9.2T513-626q0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2zm.29 514q-82.74.0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66T197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5T763-763t85.5 127T880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80z"/></svg> </span><strong>Note</strong></p><p>If <code>CMD</code> is defined from the base image, setting <code>ENTRYPOINT</code> will reset <code>CMD</code> to an empty value. In this scenario, <code>CMD</code> must be defined in the current image to have a value.</p></blockquote><h2 class=scroll-mt-20 id=volume><a class="text-black dark:text-white no-underline hover:underline" href=#volume>VOLUME</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Vk9MVU1FIFsiL2RhdGEiXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>VOLUME</span> <span class=p>[</span><span class=s2>"/data"</span><span class=p>]</span></span></span></code></pre></div></div></div></div><p>The <code>VOLUME</code> instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers. The value can be a JSON array, <code>VOLUME ["/var/log/"]</code>, or a plain string with multiple arguments, such as <code>VOLUME /var/log</code> or <code>VOLUME /var/log /var/db</code>. For more information/examples and mounting instructions via the Docker client, refer to <a class=link href=https://docs.docker.com/storage/volumes/ rel=noopener><em>Share Directories via Volumes</em><span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> documentation.</p><p>The <code>docker run</code> command initializes the newly created volume with any data that exists at the specified location within the base image. For example, consider the following Dockerfile snippet:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKUlVOIG1rZGlyIC9teXZvbApSVU4gZWNobyAiaGVsbG8gd29ybGQiID4gL215dm9sL2dyZWV0aW5nClZPTFVNRSAvbXl2b2w=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> mkdir /myvol<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>"hello world"</span> > /myvol/greeting<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>VOLUME</span><span class=s> /myvol</span></span></span></code></pre></div></div></div></div><p>This Dockerfile results in an image that causes <code>docker run</code> to create a new mount point at <code>/myvol</code> and copy the <code>greeting</code> file into the newly created volume.</p><h3 class=scroll-mt-20 id=notes-about-specifying-volumes><a class="text-black dark:text-white no-underline hover:underline" href=#notes-about-specifying-volumes>Notes about specifying volumes</a></h3><p>Keep the following things in mind about volumes in the Dockerfile.</p><ul><li><p><strong>Volumes on Windows-based containers</strong>: When using Windows-based containers, the destination of a volume inside the container must be one of:</p><ul><li>a non-existing or empty directory</li><li>a drive other than <code>C:</code></li></ul></li><li><p><strong>Changing the volume from within the Dockerfile</strong>: If any build steps change the data within the volume after it has been declared, those changes will be discarded when using the legacy builder. When using Buildkit, the changes will instead be kept.</p></li><li><p><strong>JSON formatting</strong>: The list is parsed as a JSON array. You must enclose words with double quotes (<code>"</code>) rather than single quotes (<code>'</code>).</p></li><li><p><strong>The host directory is declared at container run-time</strong>: The host directory (the mountpoint) is, by its nature, host-dependent. This is to preserve image portability, since a given host directory can't be guaranteed to be available on all hosts. For this reason, you can't mount a host directory from within the Dockerfile. The <code>VOLUME</code> instruction does not support specifying a <code>host-dir</code> parameter. You must specify the mountpoint when you create or run the container.</p></li></ul><h2 class=scroll-mt-20 id=user><a class="text-black dark:text-white no-underline hover:underline" href=#user>USER</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'VVNFUiA8dXNlcj5bOjxncm91cD5d', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>USER</span><span class=s> <user>[:<group>]</span></span></span></code></pre></div></div></div></div><p>or</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'VVNFUiA8VUlEPls6PEdJRD5d', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>USER</span><span class=s> <UID>[:<GID>]</span></span></span></code></pre></div></div></div></div><p>The <code>USER</code> instruction sets the user name (or UID) and optionally the user group (or GID) to use as the default user and group for the remainder of the current stage. The specified user is used for <code>RUN</code> instructions and at runtime, runs the relevant <code>ENTRYPOINT</code> and <code>CMD</code> commands.</p><blockquote class="px-4 border-l-4 text-gray-light dark:text-gray-dark"><p>Note that when specifying a group for the user, the user will have <em>only</em> the specified group membership. Any other configured group memberships will be ignored.</p></blockquote><blockquote class="px-4 border-l-4 border-amber-light dark:border-amber-dark"><p class="flex gap-2 items-center text-amber-light dark:text-amber-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M92-120q-9 0-15.65-4.13Q69.7-128.25 66-135q-4.17-6.6-4.58-14.3Q61-157 66-165l388-670q5-8 11.5-11.5T480-850t14.5 3.5T506-835l388 670q5 8 4.58 15.7-.41 7.7-4.58 14.3-3.7 6.75-10.35 10.87Q877-120 868-120H92zm392.18-117q12.82.0 21.32-8.68 8.5-8.67 8.5-21.5.0-12.82-8.68-21.32-8.67-8.5-21.5-8.5-12.82.0-21.32 8.68-8.5 8.67-8.5 21.5.0 12.82 8.68 21.32 8.67 8.5 21.5 8.5zm0-111q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-164q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v164q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63z"/></svg> </span><strong>Warning</strong></p><p>When the user doesn't have a primary group then the image (or the next instructions) will be run with the <code>root</code> group.</p><p>On Windows, the user must be created first if it's not a built-in account. This can be done with the <code>net user</code> command called as part of a Dockerfile.</p></blockquote><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvd2luZG93c3NlcnZlcmNvcmUKIyBDcmVhdGUgV2luZG93cyB1c2VyIGluIHRoZSBjb250YWluZXIKUlVOIG5ldCB1c2VyIC9hZGQgcGF0cmljawojIFNldCBpdCBmb3Igc3Vic2VxdWVudCBjb21tYW5kcwpVU0VSIHBhdHJpY2s=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/windowsservercore</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Create Windows user in the container</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> net user /add patrick<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Set it for subsequent commands</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> patrick</span></span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=workdir><a class="text-black dark:text-white no-underline hover:underline" href=#workdir>WORKDIR</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvcGF0aC90by93b3JrZGly', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /path/to/workdir</span></span></span></code></pre></div></div></div></div><p>The <code>WORKDIR</code> instruction sets the working directory for any <code>RUN</code>, <code>CMD</code>, <code>ENTRYPOINT</code>, <code>COPY</code> and <code>ADD</code> instructions that follow it in the Dockerfile. If the <code>WORKDIR</code> doesn't exist, it will be created even if it's not used in any subsequent Dockerfile instruction.</p><p>The <code>WORKDIR</code> instruction can be used multiple times in a Dockerfile. If a relative path is provided, it will be relative to the path of the previous <code>WORKDIR</code> instruction. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvYQpXT1JLRElSIGIKV09SS0RJUiBjClJVTiBwd2Q=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /a</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> b</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> c</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pwd</span></span></code></pre></div></div></div></div><p>The output of the final <code>pwd</code> command in this Dockerfile would be <code>/a/b/c</code>.</p><p>The <code>WORKDIR</code> instruction can resolve environment variables previously set using <code>ENV</code>. You can only use environment variables explicitly set in the Dockerfile. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RU5WIERJUlBBVEg9L3BhdGgKV09SS0RJUiAkRElSUEFUSC8kRElSTkFNRQpSVU4gcHdk', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>DIRPATH</span><span class=o>=</span>/path<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> $DIRPATH/$DIRNAME</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pwd</span></span></code></pre></div></div></div></div><p>The output of the final <code>pwd</code> command in this Dockerfile would be <code>/path/$DIRNAME</code></p><p>If not specified, the default working directory is <code>/</code>. In practice, if you aren't building a Dockerfile from scratch (<code>FROM scratch</code>), the <code>WORKDIR</code> may likely be set by the base image you're using.</p><p>Therefore, to avoid unintended operations in unknown directories, it's best practice to set your <code>WORKDIR</code> explicitly.</p><h2 class=scroll-mt-20 id=arg><a class="text-black dark:text-white no-underline hover:underline" href=#arg>ARG</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'QVJHIDxuYW1lPls9PGRlZmF1bHQgdmFsdWU+XSBbPG5hbWU+Wz08ZGVmYXVsdCB2YWx1ZT5dLi4uXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <name><span class=o>[=</span><default value><span class=o>]</span> <span class=o>[</span><name><span class=o>[=</span><default value><span class=o>]</span>...<span class=o>]</span></span></span></code></pre></div></div></div></div><p>The <code>ARG</code> instruction defines a variable that users can pass at build-time to the builder with the <code>docker build</code> command using the <code>--build-arg <varname>=<value></code> flag.</p><blockquote class="px-4 border-l-4 border-amber-light dark:border-amber-dark"><p class="flex gap-2 items-center text-amber-light dark:text-amber-dark"><span class="icon-svg pb-1"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M92-120q-9 0-15.65-4.13Q69.7-128.25 66-135q-4.17-6.6-4.58-14.3Q61-157 66-165l388-670q5-8 11.5-11.5T480-850t14.5 3.5T506-835l388 670q5 8 4.58 15.7-.41 7.7-4.58 14.3-3.7 6.75-10.35 10.87Q877-120 868-120H92zm392.18-117q12.82.0 21.32-8.68 8.5-8.67 8.5-21.5.0-12.82-8.68-21.32-8.67-8.5-21.5-8.5-12.82.0-21.32 8.68-8.5 8.67-8.5 21.5.0 12.82 8.68 21.32 8.67 8.5 21.5 8.5zm0-111q12.82.0 21.32-8.63 8.5-8.62 8.5-21.37v-164q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82.0-21.32 8.62-8.5 8.63-8.5 21.38v164q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63z"/></svg> </span><strong>Warning</strong></p><p>It isn't recommended to use build arguments for passing secrets such as user credentials, API tokens, etc. Build arguments are visible in the <code>docker history</code> command and in <code>max</code> mode provenance attestations, which are attached to the image by default if you use the Buildx GitHub Actions and your GitHub repository is public.</p><p>Refer to the <a class=link href=#run---mounttypesecret><code>RUN --mount=type=secret</code></a> section to learn about secure ways to use secrets when building images.</p></blockquote><p>A Dockerfile may include one or more <code>ARG</code> instructions. For example, the following is a valid Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkFSRyB1c2VyMQpBUkcgYnVpbGRubwojIC4uLg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> user1<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> buildno<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ...</span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=default-values><a class="text-black dark:text-white no-underline hover:underline" href=#default-values>Default values</a></h3><p>An <code>ARG</code> instruction can optionally include a default value:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkFSRyB1c2VyMT1zb21ldXNlcgpBUkcgYnVpbGRubz0xCiMgLi4u', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>user1</span><span class=o>=</span>someuser </span></span><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>buildno</span><span class=o>=</span><span class=m>1</span> </span></span><span class=line><span class=cl><span class=c># ...</span></span></span></code></pre></div></div></div></div><p>If an <code>ARG</code> instruction has a default value and if there is no value passed at build-time, the builder uses the default.</p><h3 class=scroll-mt-20 id=scope><a class="text-black dark:text-white no-underline hover:underline" href=#scope>Scope</a></h3><p>An <code>ARG</code> variable comes into effect from the line on which it is declared in the Dockerfile. For example, consider this Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94ClVTRVIgJHt1c2VybmFtZTotc29tZV91c2VyfQpBUkcgdXNlcm5hbWUKVVNFUiAkdXNlcm5hbWUKIyAuLi4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> ${username:-some_user}</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> username<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> $username</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ...</span></span></span></code></pre></div></div></div></div><p>A user builds this file by calling:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgdXNlcm5hbWU9d2hhdF91c2VyIC4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>username</span><span class=o>=</span>what_user . </span></span></code></pre></div></div></div></div><ul><li>The <code>USER</code> instruction on line 2 evaluates to the <code>some_user</code> fallback, because the <code>username</code> variable is not yet declared.</li><li>The <code>username</code> variable is declared on line 3, and available for reference in Dockerfile instruction from that point onwards.</li><li>The <code>USER</code> instruction on line 4 evaluates to <code>what_user</code>, since at that point the <code>username</code> argument has a value of <code>what_user</code> which was passed on the command line. Prior to its definition by an <code>ARG</code> instruction, any use of a variable results in an empty string.</li></ul><p>An <code>ARG</code> variable declared within a build stage is automatically inherited by other stages based on that stage. Unrelated build stages do not have access to the variable. To use an argument in multiple distinct stages, each stage must include the <code>ARG</code> instruction, or they must both be based on a shared base stage in the same Dockerfile where the variable is declared.</p><p>For more information, refer to <a class=link href=https://docs.docker.com/build/building/variables/#scoping rel=noopener>variable scoping<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=using-arg-variables><a class="text-black dark:text-white no-underline hover:underline" href=#using-arg-variables>Using ARG variables</a></h3><p>You can use an <code>ARG</code> or an <code>ENV</code> instruction to specify variables that are available to the <code>RUN</code> instruction. Environment variables defined using the <code>ENV</code> instruction always override an <code>ARG</code> instruction of the same name. Consider this Dockerfile with an <code>ENV</code> and <code>ARG</code> instruction.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPXYxLjAuMApSVU4gZWNobyAkQ09OVF9JTUdfVkVS', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span>v1.0.0<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div></div><p>Then, assume this image is built with this command:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgQ09OVF9JTUdfVkVSPXYyLjAuMSAu', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>CONT_IMG_VER</span><span class=o>=</span>v2.0.1 . </span></span></code></pre></div></div></div></div><p>In this case, the <code>RUN</code> instruction uses <code>v1.0.0</code> instead of the <code>ARG</code> setting passed by the user:<code>v2.0.1</code> This behavior is similar to a shell script where a locally scoped variable overrides the variables passed as arguments or inherited from environment, from its point of definition.</p><p>Using the example above but a different <code>ENV</code> specification you can create more useful interactions between <code>ARG</code> and <code>ENV</code> instructions:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPSR7Q09OVF9JTUdfVkVSOi12MS4wLjB9ClJVTiBlY2hvICRDT05UX0lNR19WRVI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span><span class=si>${</span><span class=nv>CONT_IMG_VER</span><span class=k>:-</span><span class=nv>v1</span><span class=p>.0.0</span><span class=si>}</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div></div><p>Unlike an <code>ARG</code> instruction, <code>ENV</code> values are always persisted in the built image. Consider a docker build without the <code>--build-arg</code> flag:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build . </span></span></code></pre></div></div></div></div><p>Using this Dockerfile example, <code>CONT_IMG_VER</code> is still persisted in the image but its value would be <code>v1.0.0</code> as it is the default set in line 3 by the <code>ENV</code> instruction.</p><p>The variable expansion technique in this example allows you to pass arguments from the command line and persist them in the final image by leveraging the <code>ENV</code> instruction. Variable expansion is only supported for <a class=link href=#environment-replacement>a limited set of Dockerfile instructions.</a></p><h3 class=scroll-mt-20 id=predefined-args><a class="text-black dark:text-white no-underline hover:underline" href=#predefined-args>Predefined ARGs</a></h3><p>Docker has a set of predefined <code>ARG</code> variables that you can use without a corresponding <code>ARG</code> instruction in the Dockerfile.</p><ul><li><code>HTTP_PROXY</code></li><li><code>http_proxy</code></li><li><code>HTTPS_PROXY</code></li><li><code>https_proxy</code></li><li><code>FTP_PROXY</code></li><li><code>ftp_proxy</code></li><li><code>NO_PROXY</code></li><li><code>no_proxy</code></li><li><code>ALL_PROXY</code></li><li><code>all_proxy</code></li></ul><p>To use these, pass them on the command line using the <code>--build-arg</code> flag, for example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgSFRUUFNfUFJPWFk9aHR0cHM6Ly9teS1wcm94eS5leGFtcGxlLmNvbSAu', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>HTTPS_PROXY</span><span class=o>=</span>https://my-proxy.example.com . </span></span></code></pre></div></div></div></div><p>By default, these pre-defined variables are excluded from the output of <code>docker history</code>. Excluding them reduces the risk of accidentally leaking sensitive authentication information in an <code>HTTP_PROXY</code> variable.</p><p>For example, consider building the following Dockerfile using <code>--build-arg HTTP_PROXY=http://user:pass@proxy.lon.example.com</code></p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKUlVOIGVjaG8gIkhlbGxvIFdvcmxkIg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>"Hello World"</span></span></span></code></pre></div></div></div></div><p>In this case, the value of the <code>HTTP_PROXY</code> variable is not available in the <code>docker history</code> and is not cached. If you were to change location, and your proxy server changed to <code>http://user:pass@proxy.sfo.example.com</code>, a subsequent build does not result in a cache miss.</p><p>If you need to override this behaviour then you may do so by adding an <code>ARG</code> statement in the Dockerfile as follows:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIEhUVFBfUFJPWFkKUlVOIGVjaG8gIkhlbGxvIFdvcmxkIg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> HTTP_PROXY<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>"Hello World"</span></span></span></code></pre></div></div></div></div><p>When building this Dockerfile, the <code>HTTP_PROXY</code> is preserved in the <code>docker history</code>, and changing its value invalidates the build cache.</p><h3 class=scroll-mt-20 id=automatic-platform-args-in-the-global-scope><a class="text-black dark:text-white no-underline hover:underline" href=#automatic-platform-args-in-the-global-scope>Automatic platform ARGs in the global scope</a></h3><p>This feature is only available when using the <a class=link href=https://docs.docker.com/build/buildkit/ rel=noopener>BuildKit<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> backend.</p><p>BuildKit supports a predefined set of <code>ARG</code> variables with information on the platform of the node performing the build (build platform) and on the platform of the resulting image (target platform). The target platform can be specified with the <code>--platform</code> flag on <code>docker build</code>.</p><p>The following <code>ARG</code> variables are set automatically:</p><ul><li><code>TARGETPLATFORM</code> - platform of the build result. Eg <code>linux/amd64</code>, <code>linux/arm/v7</code>, <code>windows/amd64</code>.</li><li><code>TARGETOS</code> - OS component of TARGETPLATFORM</li><li><code>TARGETARCH</code> - architecture component of TARGETPLATFORM</li><li><code>TARGETVARIANT</code> - variant component of TARGETPLATFORM</li><li><code>BUILDPLATFORM</code> - platform of the node performing the build.</li><li><code>BUILDOS</code> - OS component of BUILDPLATFORM</li><li><code>BUILDARCH</code> - architecture component of BUILDPLATFORM</li><li><code>BUILDVARIANT</code> - variant component of BUILDPLATFORM</li></ul><p>These arguments are defined in the global scope so are not automatically available inside build stages or for your <code>RUN</code> commands. To expose one of these arguments inside the build stage redefine it without value.</p><p>For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBhbHBpbmUKQVJHIFRBUkdFVFBMQVRGT1JNClJVTiBlY2hvICJJJ20gYnVpbGRpbmcgZm9yICRUQVJHRVRQTEFURk9STSI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> TARGETPLATFORM<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>"I'm building for </span><span class=nv>$TARGETPLATFORM</span><span class=s2>"</span></span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=buildkit-built-in-build-args><a class="text-black dark:text-white no-underline hover:underline" href=#buildkit-built-in-build-args>BuildKit built-in build args</a></h3><div class=overflow-x-auto><table><thead class="bg-gray-light-100 dark:bg-gray-dark-200"><tr><th class=p-2>Arg</th><th class=p-2>Type</th><th class=p-2>Description</th></tr></thead><tbody><tr><td class=p-2><code>BUILDKIT_CACHE_MOUNT_NS</code></td><td class=p-2>String</td><td class=p-2>Set optional cache ID namespace.</td></tr><tr><td class=p-2><code>BUILDKIT_CONTEXT_KEEP_GIT_DIR</code></td><td class=p-2>Bool</td><td class=p-2>Trigger Git context to keep the <code>.git</code> directory.</td></tr><tr><td class=p-2><code>BUILDKIT_INLINE_CACHE</code><sup id=fnref:2><a href=#fn:2 class=footnote-ref role=doc-noteref>2</a></sup></td><td class=p-2>Bool</td><td class=p-2>Inline cache metadata to image config or not.</td></tr><tr><td class=p-2><code>BUILDKIT_MULTI_PLATFORM</code></td><td class=p-2>Bool</td><td class=p-2>Opt into deterministic output regardless of multi-platform output or not.</td></tr><tr><td class=p-2><code>BUILDKIT_SANDBOX_HOSTNAME</code></td><td class=p-2>String</td><td class=p-2>Set the hostname (default <code>buildkitsandbox</code>)</td></tr><tr><td class=p-2><code>BUILDKIT_SYNTAX</code></td><td class=p-2>String</td><td class=p-2>Set frontend image</td></tr><tr><td class=p-2><code>SOURCE_DATE_EPOCH</code></td><td class=p-2>Int</td><td class=p-2>Set the Unix timestamp for created image and layers. More info from <a class=link href=https://reproducible-builds.org/docs/source-date-epoch/ rel=noopener>reproducible builds<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a>. Supported since Dockerfile 1.5, BuildKit 0.11</td></tr></tbody></table></div><h4 class=scroll-mt-20 id=example-keep-git-dir><a class="text-black dark:text-white no-underline hover:underline" href=#example-keep-git-dir>Example: keep <code>.git</code> dir</a></h4><p>When using a Git context, <code>.git</code> dir is not kept on checkouts. It can be useful to keep it around if you want to retrieve git information during your build:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpXT1JLRElSIC9zcmMKUlVOIC0tbW91bnQ9dGFyZ2V0PS4gXAogIG1ha2UgUkVWSVNJT049JChnaXQgcmV2LXBhcnNlIEhFQUQpIGJ1aWxk', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> /src</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>target</span><span class=o>=</span>. <span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span> make <span class=nv>REVISION</span><span class=o>=</span><span class=k>$(</span>git rev-parse HEAD<span class=k>)</span> build</span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgQlVJTERLSVRfQ09OVEVYVF9LRUVQX0dJVF9ESVI9MSBodHRwczovL2dpdGh1Yi5jb20vdXNlci9yZXBvLmdpdCNtYWlu', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>BUILDKIT_CONTEXT_KEEP_GIT_DIR</span><span class=o>=</span><span class=m>1</span> https://github.com/user/repo.git#main </span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=impact-on-build-caching><a class="text-black dark:text-white no-underline hover:underline" href=#impact-on-build-caching>Impact on build caching</a></h3><p><code>ARG</code> variables are not persisted into the built image as <code>ENV</code> variables are. However, <code>ARG</code> variables do impact the build cache in similar ways. If a Dockerfile defines an <code>ARG</code> variable whose value is different from a previous build, then a "cache miss" occurs upon its first usage, not its definition. In particular, all <code>RUN</code> instructions following an <code>ARG</code> instruction use the <code>ARG</code> variable implicitly (as an environment variable), thus can cause a cache miss. All predefined <code>ARG</code> variables are exempt from caching unless there is a matching <code>ARG</code> statement in the Dockerfile.</p><p>For example, consider these two Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpSVU4gZWNobyAkQ09OVF9JTUdfVkVS', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div></div><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpSVU4gZWNobyBoZWxsbw==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div></div><p>If you specify <code>--build-arg CONT_IMG_VER=<value></code> on the command line, in both cases, the specification on line 2 doesn't cause a cache miss; line 3 does cause a cache miss. <code>ARG CONT_IMG_VER</code> causes the <code>RUN</code> line to be identified as the same as running <code>CONT_IMG_VER=<value> echo hello</code>, so if the <code><value></code> changes, you get a cache miss.</p><p>Consider another example under the same command line:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPSRDT05UX0lNR19WRVIKUlVOIGVjaG8gJENPTlRfSU1HX1ZFUg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span><span class=nv>$CONT_IMG_VER</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div></div><p>In this example, the cache miss occurs on line 3. The miss happens because the variable's value in the <code>ENV</code> references the <code>ARG</code> variable and that variable is changed through the command line. In this example, the <code>ENV</code> command causes the image to include the value.</p><p>If an <code>ENV</code> instruction overrides an <code>ARG</code> instruction of the same name, like this Dockerfile:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPWhlbGxvClJVTiBlY2hvICRDT05UX0lNR19WRVI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span>hello </span></span><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div></div><p>Line 3 doesn't cause a cache miss because the value of <code>CONT_IMG_VER</code> is a constant (<code>hello</code>). As a result, the environment variables and values used on the <code>RUN</code> (line 4) doesn't change between builds.</p><h2 class=scroll-mt-20 id=onbuild><a class="text-black dark:text-white no-underline hover:underline" href=#onbuild>ONBUILD</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'T05CVUlMRCA8SU5TVFJVQ1RJT04+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ONBUILD</span> <INSTRUCTION></span></span></code></pre></div></div></div></div><p>The <code>ONBUILD</code> instruction adds to the image a trigger instruction to be executed at a later time, when the image is used as the base for another build. The trigger will be executed in the context of the downstream build, as if it had been inserted immediately after the <code>FROM</code> instruction in the downstream Dockerfile.</p><p>This is useful if you are building an image which will be used as a base to build other images, for example an application build environment or a daemon which may be customized with user-specific configuration.</p><p>For example, if your image is a reusable Python application builder, it will require application source code to be added in a particular directory, and it might require a build script to be called after that. You can't just call <code>ADD</code> and <code>RUN</code> now, because you don't yet have access to the application source code, and it will be different for each application build. You could simply provide application developers with a boilerplate Dockerfile to copy-paste into their application, but that's inefficient, error-prone and difficult to update because it mixes with application-specific code.</p><p>The solution is to use <code>ONBUILD</code> to register advance instructions to run later, during the next build stage.</p><p>Here's how it works:</p><ol><li>When it encounters an <code>ONBUILD</code> instruction, the builder adds a trigger to the metadata of the image being built. The instruction doesn't otherwise affect the current build.</li><li>At the end of the build, a list of all triggers is stored in the image manifest, under the key <code>OnBuild</code>. They can be inspected with the <code>docker inspect</code> command.</li><li>Later the image may be used as a base for a new build, using the <code>FROM</code> instruction. As part of processing the <code>FROM</code> instruction, the downstream builder looks for <code>ONBUILD</code> triggers, and executes them in the same order they were registered. If any of the triggers fail, the <code>FROM</code> instruction is aborted which in turn causes the build to fail. If all triggers succeed, the <code>FROM</code> instruction completes and the build continues as usual.</li><li>Triggers are cleared from the final image after being executed. In other words they aren't inherited by "grand-children" builds.</li></ol><p>For example you might add something like this:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'T05CVUlMRCBBREQgLiAvYXBwL3NyYwpPTkJVSUxEIFJVTiAvdXNyL2xvY2FsL2Jpbi9weXRob24tYnVpbGQgLS1kaXIgL2FwcC9zcmM=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ONBUILD</span> <span class=k>ADD</span> . /app/src<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ONBUILD</span> <span class=k>RUN</span> /usr/local/bin/python-build --dir /app/src</span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=copy-or-mount-from-stage-image-or-context><a class="text-black dark:text-white no-underline hover:underline" href=#copy-or-mount-from-stage-image-or-context>Copy or mount from stage, image, or context</a></h3><p>As of Dockerfile syntax 1.11, you can use <code>ONBUILD</code> with instructions that copy or mount files from other stages, images, or build contexts. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS4xMQpGUk9NIGFscGluZSBBUyBiYXNlaW1hZ2UKT05CVUlMRCBDT1BZIC0tZnJvbT1idWlsZCAvdXNyL2Jpbi9hcHAgL2FwcApPTkJVSUxEIFJVTiAtLW1vdW50PWZyb209Y29uZmlnLHRhcmdldD0vb3B0L2FwcGNvbmZpZyAuLi4=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1.11</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine AS baseimage</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ONBUILD</span> <span class=k>COPY</span> --from<span class=o>=</span>build /usr/bin/app /app<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ONBUILD</span> <span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>from</span><span class=o>=</span>config,target<span class=o>=</span>/opt/appconfig ...</span></span></code></pre></div></div></div></div><p>If the source of <code>from</code> is a build stage, the stage must be defined in the Dockerfile where <code>ONBUILD</code> gets triggered. If it's a named context, that context must be passed to the downstream build.</p><h3 class=scroll-mt-20 id=onbuild-limitations><a class="text-black dark:text-white no-underline hover:underline" href=#onbuild-limitations>ONBUILD limitations</a></h3><ul><li>Chaining <code>ONBUILD</code> instructions using <code>ONBUILD ONBUILD</code> isn't allowed.</li><li>The <code>ONBUILD</code> instruction may not trigger <code>FROM</code> or <code>MAINTAINER</code> instructions.</li></ul><h2 class=scroll-mt-20 id=stopsignal><a class="text-black dark:text-white no-underline hover:underline" href=#stopsignal>STOPSIGNAL</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'U1RPUFNJR05BTCBzaWduYWw=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>STOPSIGNAL</span><span class=s> signal</span></span></span></code></pre></div></div></div></div><p>The <code>STOPSIGNAL</code> instruction sets the system call signal that will be sent to the container to exit. This signal can be a signal name in the format <code>SIG<NAME></code>, for instance <code>SIGKILL</code>, or an unsigned number that matches a position in the kernel's syscall table, for instance <code>9</code>. The default is <code>SIGTERM</code> if not defined.</p><p>The image's default stopsignal can be overridden per container, using the <code>--stop-signal</code> flag on <code>docker run</code> and <code>docker create</code>.</p><h2 class=scroll-mt-20 id=healthcheck><a class="text-black dark:text-white no-underline hover:underline" href=#healthcheck>HEALTHCHECK</a></h2><p>The <code>HEALTHCHECK</code> instruction has two forms:</p><ul><li><code>HEALTHCHECK [OPTIONS] CMD command</code> (check container health by running a command inside the container)</li><li><code>HEALTHCHECK NONE</code> (disable any healthcheck inherited from the base image)</li></ul><p>The <code>HEALTHCHECK</code> instruction tells Docker how to test a container to check that it's still working. This can detect cases such as a web server stuck in an infinite loop and unable to handle new connections, even though the server process is still running.</p><p>When a container has a healthcheck specified, it has a health status in addition to its normal status. This status is initially <code>starting</code>. Whenever a health check passes, it becomes <code>healthy</code> (whatever state it was previously in). After a certain number of consecutive failures, it becomes <code>unhealthy</code>.</p><p>The options that can appear before <code>CMD</code> are:</p><ul><li><code>--interval=DURATION</code> (default: <code>30s</code>)</li><li><code>--timeout=DURATION</code> (default: <code>30s</code>)</li><li><code>--start-period=DURATION</code> (default: <code>0s</code>)</li><li><code>--start-interval=DURATION</code> (default: <code>5s</code>)</li><li><code>--retries=N</code> (default: <code>3</code>)</li></ul><p>The health check will first run <strong>interval</strong> seconds after the container is started, and then again <strong>interval</strong> seconds after each previous check completes.</p><p>If a single run of the check takes longer than <strong>timeout</strong> seconds then the check is considered to have failed.</p><p>It takes <strong>retries</strong> consecutive failures of the health check for the container to be considered <code>unhealthy</code>.</p><p><strong>start period</strong> provides initialization time for containers that need time to bootstrap. Probe failure during that period will not be counted towards the maximum number of retries. However, if a health check succeeds during the start period, the container is considered started and all consecutive failures will be counted towards the maximum number of retries.</p><p><strong>start interval</strong> is the time between health checks during the start period. This option requires Docker Engine version 25.0 or later.</p><p>There can only be one <code>HEALTHCHECK</code> instruction in a Dockerfile. If you list more than one then only the last <code>HEALTHCHECK</code> will take effect.</p><p>The command after the <code>CMD</code> keyword can be either a shell command (e.g. <code>HEALTHCHECK CMD /bin/check-running</code>) or an exec array (as with other Dockerfile commands; see e.g. <code>ENTRYPOINT</code> for details).</p><p>The command's exit status indicates the health status of the container. The possible values are:</p><ul><li>0: success - the container is healthy and ready for use</li><li>1: unhealthy - the container isn't working correctly</li><li>2: reserved - don't use this exit code</li></ul><p>For example, to check every five minutes or so that a web-server is able to serve the site's main page within three seconds:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'SEVBTFRIQ0hFQ0sgLS1pbnRlcnZhbD01bSAtLXRpbWVvdXQ9M3MgXAogIENNRCBjdXJsIC1mIGh0dHA6Ly9sb2NhbGhvc3QvIHx8IGV4aXQgMQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=err>HEALTHCHECK --interval=5m --timeout=3s \ </span></span></span><span class=line><span class=cl><span class=err> </span><span class=k>CMD</span> curl -f http://localhost/ <span class=o>||</span> <span class=nb>exit</span> <span class=m>1</span></span></span></code></pre></div></div></div></div><p>To help debug failing probes, any output text (UTF-8 encoded) that the command writes on stdout or stderr will be stored in the health status and can be queried with <code>docker inspect</code>. Such output should be kept short (only the first 4096 bytes are stored currently).</p><p>When the health status of a container changes, a <code>health_status</code> event is generated with the new status.</p><h2 class=scroll-mt-20 id=shell><a class="text-black dark:text-white no-underline hover:underline" href=#shell>SHELL</a></h2><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'U0hFTEwgWyJleGVjdXRhYmxlIiwgInBhcmFtZXRlcnMiXQ==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>SHELL</span> <span class=p>[</span><span class=s2>"executable"</span><span class=p>,</span> <span class=s2>"parameters"</span><span class=p>]</span></span></span></code></pre></div></div></div></div><p>The <code>SHELL</code> instruction allows the default shell used for the shell form of commands to be overridden. The default shell on Linux is <code>["/bin/sh", "-c"]</code>, and on Windows is <code>["cmd", "/S", "/C"]</code>. The <code>SHELL</code> instruction must be written in JSON form in a Dockerfile.</p><p>The <code>SHELL</code> instruction is particularly useful on Windows where there are two commonly used and quite different native shells: <code>cmd</code> and <code>powershell</code>, as well as alternate shells available including <code>sh</code>.</p><p>The <code>SHELL</code> instruction can appear multiple times. Each <code>SHELL</code> instruction overrides all previous <code>SHELL</code> instructions, and affects all subsequent instructions. For example:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvd2luZG93c3NlcnZlcmNvcmUKCiMgRXhlY3V0ZWQgYXMgY21kIC9TIC9DIGVjaG8gZGVmYXVsdApSVU4gZWNobyBkZWZhdWx0CgojIEV4ZWN1dGVkIGFzIGNtZCAvUyAvQyBwb3dlcnNoZWxsIC1jb21tYW5kIFdyaXRlLUhvc3QgZGVmYXVsdApSVU4gcG93ZXJzaGVsbCAtY29tbWFuZCBXcml0ZS1Ib3N0IGRlZmF1bHQKCiMgRXhlY3V0ZWQgYXMgcG93ZXJzaGVsbCAtY29tbWFuZCBXcml0ZS1Ib3N0IGhlbGxvClNIRUxMIFsicG93ZXJzaGVsbCIsICItY29tbWFuZCJdClJVTiBXcml0ZS1Ib3N0IGhlbGxvCgojIEV4ZWN1dGVkIGFzIGNtZCAvUyAvQyBlY2hvIGhlbGxvClNIRUxMIFsiY21kIiwgIi9TIiwgIi9DIl0KUlVOIGVjaG8gaGVsbG8=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/windowsservercore</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C echo default</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> default<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C powershell -command Write-Host default</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> powershell -command Write-Host default<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as powershell -command Write-Host hello</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>"powershell"</span><span class=p>,</span> <span class=s2>"-command"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> Write-Host hello<span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C echo hello</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>"cmd"</span><span class=p>,</span> <span class=s2>"/S"</span><span class=p>,</span> <span class=s2>"/C"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div></div><p>The following instructions can be affected by the <code>SHELL</code> instruction when the shell form of them is used in a Dockerfile: <code>RUN</code>, <code>CMD</code> and <code>ENTRYPOINT</code>.</p><p>The following example is a common pattern found on Windows which can be streamlined by using the <code>SHELL</code> instruction:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIHBvd2Vyc2hlbGwgLWNvbW1hbmQgRXhlY3V0ZS1NeUNtZGxldCAtcGFyYW0xICJjOlxmb28udHh0Ig==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> powershell -command Execute-MyCmdlet -param1 <span class=s2>"c:\foo.txt"</span></span></span></code></pre></div></div></div></div><p>The command invoked by the builder will be:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'Y21kIC9TIC9DIHBvd2Vyc2hlbGwgLWNvbW1hbmQgRXhlY3V0ZS1NeUNtZGxldCAtcGFyYW0xICJjOlxmb28udHh0Ig==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-powershell data-lang=powershell><span class=line><span class=cl><span class=n>cmd</span> <span class=p>/</span><span class=n>S</span> <span class=p>/</span><span class=n>C</span> <span class=n>powershell</span> <span class=n>-command</span> <span class=nb>Execute-MyCmdlet</span> <span class=n>-param1</span> <span class=s2>"c:\foo.txt"</span></span></span></code></pre></div></div></div></div><p>This is inefficient for two reasons. First, there is an unnecessary <code>cmd.exe</code> command processor (aka shell) being invoked. Second, each <code>RUN</code> instruction in the shell form requires an extra <code>powershell -command</code> prefixing the command.</p><p>To make this more efficient, one of two mechanisms can be employed. One is to use the JSON form of the <code>RUN</code> command such as:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UlVOIFsicG93ZXJzaGVsbCIsICItY29tbWFuZCIsICJFeGVjdXRlLU15Q21kbGV0IiwgIi1wYXJhbTEgXCJjOlxcZm9vLnR4dFwiIl0=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>"powershell"</span>, <span class=s2>"-command"</span>, <span class=s2>"Execute-MyCmdlet"</span>, <span class=s2>"-param1 \"c:\\foo.txt\""</span><span class=o>]</span></span></span></code></pre></div></div></div></div><p>While the JSON form is unambiguous and does not use the unnecessary <code>cmd.exe</code>, it does require more verbosity through double-quoting and escaping. The alternate mechanism is to use the <code>SHELL</code> instruction and the shell form, making a more natural syntax for Windows users, especially when combined with the <code>escape</code> parser directive:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YAoKRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpTSEVMTCBbInBvd2Vyc2hlbGwiLCItY29tbWFuZCJdClJVTiBOZXctSXRlbSAtSXRlbVR5cGUgRGlyZWN0b3J5IEM6XEV4YW1wbGUKQUREIEV4ZWN1dGUtTXlDbWRsZXQucHMxIGM6XGV4YW1wbGVcClJVTiBjOlxleGFtcGxlXEV4ZWN1dGUtTXlDbWRsZXQgLXNhbXBsZSAnaGVsbG8gd29ybGQn', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>"powershell"</span><span class=p>,</span><span class=s2>"-command"</span><span class=p>]</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> New-Item -ItemType Directory C:<span class=se>\E</span>xample<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> Execute-MyCmdlet.ps1 c:<span class=se>\e</span>xample<span class=se>\ </span></span></span><span class=line><span class=cl><span class=se></span>RUN c:<span class=se>\e</span>xample<span class=se>\E</span>xecute-MyCmdlet -sample <span class=s1>'hello world'</span></span></span></code></pre></div></div></div></div><p>Resulting in:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgc2hlbGwgLgoKU2VuZGluZyBidWlsZCBjb250ZXh0IHRvIERvY2tlciBkYWVtb24gNC4wOTYga0IKU3RlcCAxLzUgOiBGUk9NIG1pY3Jvc29mdC9uYW5vc2VydmVyCiAtLS0+IDIyNzM4ZmY0OWM2ZApTdGVwIDIvNSA6IFNIRUxMIHBvd2Vyc2hlbGwgLWNvbW1hbmQKIC0tLT4gUnVubmluZyBpbiA2ZmNkYjY4NTVhZTIKIC0tLT4gNjMzMTQ2MmQ0MzAwClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgNmZjZGI2ODU1YWUyClN0ZXAgMy81IDogUlVOIE5ldy1JdGVtIC1JdGVtVHlwZSBEaXJlY3RvcnkgQzpcRXhhbXBsZQogLS0tPiBSdW5uaW5nIGluIGQwZWVmODM4NmU5NwoKCiAgICBEaXJlY3Rvcnk6IEM6XAoKCk1vZGUgICAgICAgICBMYXN0V3JpdGVUaW1lICAgICAgICAgICAgICBMZW5ndGggTmFtZQotLS0tICAgICAgICAgLS0tLS0tLS0tLS0tLSAgICAgICAgICAgICAgLS0tLS0tIC0tLS0KZC0tLS0tICAgICAgIDEwLzI4LzIwMTYgIDExOjI2IEFNICAgICAgICAgICAgICBFeGFtcGxlCgoKIC0tLT4gM2YyZmJmMTM5NWQ5ClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgZDBlZWY4Mzg2ZTk3ClN0ZXAgNC81IDogQUREIEV4ZWN1dGUtTXlDbWRsZXQucHMxIGM6XGV4YW1wbGVcCiAtLS0+IGE5NTViMjYyMWMzMQpSZW1vdmluZyBpbnRlcm1lZGlhdGUgY29udGFpbmVyIGI4MjU1OTNkMzlmYwpTdGVwIDUvNSA6IFJVTiBjOlxleGFtcGxlXEV4ZWN1dGUtTXlDbWRsZXQgJ2hlbGxvIHdvcmxkJwogLS0tPiBSdW5uaW5nIGluIGJlNmQ4ZTYzZmU3NQpoZWxsbyB3b3JsZAogLS0tPiA4ZTU1OWU5YmY0MjQKUmVtb3ZpbmcgaW50ZXJtZWRpYXRlIGNvbnRhaW5lciBiZTZkOGU2M2ZlNzUKU3VjY2Vzc2Z1bGx5IGJ1aWx0IDhlNTU5ZTliZjQyNApQUyBFOlxteXByb2plY3Q+', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject> docker build -t shell . </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 4.096 kB </span></span></span><span class=line><span class=cl><span class=go>Step 1/5 : FROM microsoft/nanoserver </span></span></span><span class=line><span class=cl><span class=go> ---> 22738ff49c6d </span></span></span><span class=line><span class=cl><span class=go>Step 2/5 : SHELL powershell -command </span></span></span><span class=line><span class=cl><span class=go> ---> Running in 6fcdb6855ae2 </span></span></span><span class=line><span class=cl><span class=go> ---> 6331462d4300 </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container 6fcdb6855ae2 </span></span></span><span class=line><span class=cl><span class=go>Step 3/5 : RUN New-Item -ItemType Directory C:\Example </span></span></span><span class=line><span class=cl><span class=go> ---> Running in d0eef8386e97 </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go> Directory: C:\ </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Mode LastWriteTime Length Name </span></span></span><span class=line><span class=cl><span class=go>---- ------------- ------ ---- </span></span></span><span class=line><span class=cl><span class=go>d----- 10/28/2016 11:26 AM Example </span></span></span><span class=line><span class=cl><span class=go></span><span class=err> </span></span></span><span class=line><span class=cl><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=go> ---> 3f2fbf1395d9 </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container d0eef8386e97 </span></span></span><span class=line><span class=cl><span class=go>Step 4/5 : ADD Execute-MyCmdlet.ps1 c:\example\ </span></span></span><span class=line><span class=cl><span class=go> ---> a955b2621c31 </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container b825593d39fc </span></span></span><span class=line><span class=cl><span class=go>Step 5/5 : RUN c:\example\Execute-MyCmdlet 'hello world' </span></span></span><span class=line><span class=cl><span class=go> ---> Running in be6d8e63fe75 </span></span></span><span class=line><span class=cl><span class=go>hello world </span></span></span><span class=line><span class=cl><span class=go> ---> 8e559e9bf424 </span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container be6d8e63fe75 </span></span></span><span class=line><span class=cl><span class=go>Successfully built 8e559e9bf424 </span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject> </span></span></span></code></pre></div></div></div></div><p>The <code>SHELL</code> instruction could also be used to modify the way in which a shell operates. For example, using <code>SHELL cmd /S /C /V:ON|OFF</code> on Windows, delayed environment variable expansion semantics could be modified.</p><p>The <code>SHELL</code> instruction can also be used on Linux should an alternate shell be required such as <code>zsh</code>, <code>csh</code>, <code>tcsh</code> and others.</p><h2 class=scroll-mt-20 id=here-documents><a class="text-black dark:text-white no-underline hover:underline" href=#here-documents>Here-Documents</a></h2><p>Here-documents allow redirection of subsequent Dockerfile lines to the input of <code>RUN</code> or <code>COPY</code> commands. If such command contains a <a class=link href=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 rel=noopener>here-document<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> the Dockerfile considers the next lines until the line only containing a here-doc delimiter as part of the same command.</p><h3 class=scroll-mt-20 id=example-running-a-multi-line-script><a class="text-black dark:text-white no-underline hover:underline" href=#example-running-a-multi-line-script>Example: Running a multi-line script</a></h3><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGRlYmlhbgpSVU4gPDxFT1QgYmFzaAogIHNldCAtZXgKICBhcHQtZ2V0IHVwZGF0ZQogIGFwdC1nZXQgaW5zdGFsbCAteSB2aW0KRU9U', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> debian</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <<EOT bash<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> <span class=nb>set</span> -ex<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> apt-get update<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> apt-get install -y vim<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div></div><p>If the command only contains a here-document, its contents is evaluated with the default shell.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGRlYmlhbgpSVU4gPDxFT1QKICBta2RpciAtcCBmb28vYmFyCkVPVA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> debian</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <<EOT<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> mkdir -p foo/bar<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div></div><p>Alternatively, shebang header can be used to define an interpreter.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozLjYKUlVOIDw8RU9UCiMhL3Vzci9iaW4vZW52IHB5dGhvbgpwcmludCgiaGVsbG8gd29ybGQiKQpFT1Q=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3.6</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <<EOT<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=c>#!/usr/bin/env python</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>print<span class=o>(</span><span class=s2>"hello world"</span><span class=o>)</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div></div><p>More complex examples may use multiple here-documents.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpSVU4gPDxGSUxFMSBjYXQgPiBmaWxlMSAmJiA8PEZJTEUyIGNhdCA+IGZpbGUyCkkgYW0KZmlyc3QKRklMRTEKSSBhbQpzZWNvbmQKRklMRTI=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=s><<FILE1 cat > file1 && <<FILE</span><span class=m>2</span> cat > file2<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>I am<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>first<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>FILE1<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>I am<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>second<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>FILE2</span></span></code></pre></div></div></div></div><h3 class=scroll-mt-20 id=example-creating-inline-files><a class="text-black dark:text-white no-underline hover:underline" href=#example-creating-inline-files>Example: Creating inline files</a></h3><p>With <code>COPY</code> instructions, you can replace the source parameter with a here-doc indicator to write the contents of the here-document directly to a file. The following example creates a <code>greeting.txt</code> file containing <code>hello world</code> using a <code>COPY</code> instruction.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpDT1BZIDw8RU9GIGdyZWV0aW5nLnR4dApoZWxsbyB3b3JsZApFT0Y=', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> <<EOF greeting.txt<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>hello world<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div></div><p>Regular here-doc <a class=link href=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 rel=noopener>variable expansion and tab stripping rules<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> apply. The following example shows a small Dockerfile that creates a <code>hello.sh</code> script file using a <code>COPY</code> instruction with a here-document.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBUkcgRk9PPWJhcgpDT1BZIDw8LUVPVCAvc2NyaXB0LnNoCiAgZWNobyAiaGVsbG8gJHtGT099IgpFT1QKRU5UUllQT0lOVCBhc2ggL3NjcmlwdC5zaA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>FOO</span><span class=o>=</span>bar </span></span><span class=line><span class=cl><span class=k>COPY</span> <<-EOT /script.sh<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> <span class=nb>echo</span> <span class=s2>"hello </span><span class=si>${</span><span class=nv>FOO</span><span class=si>}</span><span class=s2>"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOT<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> ash /script.sh</span></span></code></pre></div></div></div></div><p>In this case, file script prints "hello bar", because the variable is expanded when the <code>COPY</code> instruction gets executed.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLXQgaGVyZWRvYyAuCiQgZG9ja2VyIHJ1biBoZXJlZG9jCmhlbGxvIGJhcg==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build -t heredoc . </span></span><span class=line><span class=cl><span class=gp>$</span> docker run heredoc </span></span><span class=line><span class=cl><span class=go>hello bar </span></span></span></code></pre></div></div></div></div><p>If instead you were to quote any part of the here-document word <code>EOT</code>, the variable would not be expanded at build-time.</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBUkcgRk9PPWJhcgpDT1BZIDw8LSJFT1QiIC9zY3JpcHQuc2gKICBlY2hvICJoZWxsbyAke0ZPT30iCkVPVApFTlRSWVBPSU5UIGFzaCAvc2NyaXB0LnNo', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>FOO</span><span class=o>=</span>bar </span></span><span class=line><span class=cl><span class=k>COPY</span> <<-<span class=s2>"EOT"</span> /script.sh<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span> <span class=nb>echo</span> <span class=s2>"hello </span><span class=si>${</span><span class=nv>FOO</span><span class=si>}</span><span class=s2>"</span><span class=err> </span></span></span><span class=line><span class=cl><span class=err></span>EOT<span class=err> </span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> ash /script.sh</span></span></code></pre></div></div></div></div><p>Note that <code>ARG FOO=bar</code> is excessive here, and can be removed. The variable gets interpreted at runtime, when the script is invoked:</p><div data-pagefind-ignore class=scroll-mt-20 x-data x-ref=root><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLXQgaGVyZWRvYyAuCiQgZG9ja2VyIHJ1biAtZSBGT089d29ybGQgaGVyZWRvYwpoZWxsbyB3b3JsZA==', copying: false }" class="absolute right-3 top-3 z-10 text-gray-light-300 dark:text-gray-dark-600" title=copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^[\$>]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> <span :class="{ 'group-hover:block' : !copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span> <span :class="{ 'group-hover:block' : copying }" class="icon-svg hidden"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build -t heredoc . </span></span><span class=line><span class=cl><span class=gp>$</span> docker run -e <span class=nv>FOO</span><span class=o>=</span>world heredoc </span></span><span class=line><span class=cl><span class=go>hello world </span></span></span></code></pre></div></div></div></div><h2 class=scroll-mt-20 id=dockerfile-examples><a class="text-black dark:text-white no-underline hover:underline" href=#dockerfile-examples>Dockerfile examples</a></h2><p>For examples of Dockerfiles, refer to:</p><ul><li>The <a class=link href=https://docs.docker.com/build/building/best-practices/ rel=noopener>building best practices page<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a></li><li>The <a class=link href=https://docs.docker.com/get-started/ rel=noopener>"get started" tutorials<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a></li><li>The <a class=link href=https://docs.docker.com/guides/language/ rel=noopener>language-specific getting started guides<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a></li></ul><div class=footnotes role=doc-endnotes><hr><ol><li id=fn:1><p>Value required <a href=#fnref:1 class=footnote-backref role=doc-backlink>↩︎</a> <a href=#fnref1:1 class=footnote-backref role=doc-backlink>↩︎</a> <a href=#fnref2:1 class=footnote-backref role=doc-backlink>↩︎</a></p></li><li id=fn:2><p>For Docker-integrated <a class=link href=https://docs.docker.com/build/buildkit/#getting-started rel=noopener>BuildKit<span class="pl-1 icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a> and <code>docker buildx build</code> <a href=#fnref:2 class=footnote-backref role=doc-backlink>↩︎</a></p></li></ol></div></article><div class="hidden flex-1 min-w-52 lg:block -mr-8 -mt-8"><aside class="sticky top-16 h-[calc(100vh-64px)] min-w-52 space-y-4 overflow-y-auto py-4 w-full"><p class="flex items-center gap-2"><span class=icon-svg><svg width="48" height="48" viewBox="0 -960 960 960"><path d="m378-332 363-363q9.27-9 21.64-9 12.36.0 21.36 9.05 9 9.06 9 21.5.0 12.45-9 21.45L399-267q-9 9-21 9t-21-9L175-449q-9-9.07-8.5-21.53.5-12.47 9.55-21.47 9.06-9 21.5-9 12.45.0 21.45 9l159 160z"/></svg></span> <a class=link rel=noopener href="https://github.com/docker/docs/issues/new?template=doc_issue.yml&location=https%3a%2f%2fdocs.docker.com%2freference%2fdockerfile%2f&labels=status%2Ftriage">Request changes<span class="icon-svg icon-sm"><svg width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H180v6e2h6e2v-249q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h261q12.75.0 21.38 8.62Q840-822.75 840-810v261q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-188z"/></svg></span></a></a></p><div id=TableOfContents><div data-pagefind-ignore class=not-prose><div class="text-lg pb-0 lg:pb-2">Table of contents</div><nav class=toc><ul class=pl-2><li><a class="link lg:no-underline" href=#overview>Overview</a></li><li><a class="link lg:no-underline" href=#format>Format</a></li><li><a class="link lg:no-underline" href=#parser-directives>Parser directives</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#syntax>syntax</a></li><li><a class="link lg:no-underline" href=#escape>escape</a></li><li><a class="link lg:no-underline" href=#check>check</a></li></ul><li><a class="link lg:no-underline" href=#environment-replacement>Environment replacement</a></li><li><a class="link lg:no-underline" href=#dockerignore-file>.dockerignore file</a></li><li><a class="link lg:no-underline" href=#shell-and-exec-form>Shell and exec form</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#exec-form>Exec form</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#shell-form>Shell form</a></li><li><a class="link lg:no-underline" href=#use-a-different-shell>Use a different shell</a></li></ul><li><a class="link lg:no-underline" href=#from>FROM</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#understand-how-arg-and-from-interact>Understand how ARG and FROM interact</a></li></ul><li><a class="link lg:no-underline" href=#run>RUN</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#cache-invalidation-for-run-instructions>Cache invalidation for RUN instructions</a></li><li><a class="link lg:no-underline" href=#run---mount>RUN --mount</a></li><li><a class="link lg:no-underline" href=#run---mounttypebind>RUN --mount=type=bind</a></li><li><a class="link lg:no-underline" href=#run---mounttypecache>RUN --mount=type=cache</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---mounttypetmpfs>RUN --mount=type=tmpfs</a></li><li><a class="link lg:no-underline" href=#run---mounttypesecret>RUN --mount=type=secret</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---mounttypessh>RUN --mount=type=ssh</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---network>RUN --network</a></li><li><a class="link lg:no-underline" href=#run---networkdefault>RUN --network=default</a></li><li><a class="link lg:no-underline" href=#run---networknone>RUN --network=none</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#run---networkhost>RUN --network=host</a></li><li><a class="link lg:no-underline" href=#run---security>RUN --security</a></li><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#cmd>CMD</a></li><li><a class="link lg:no-underline" href=#label>LABEL</a></li><li><a class="link lg:no-underline" href=#maintainer-deprecated>MAINTAINER (deprecated)</a></li><li><a class="link lg:no-underline" href=#expose>EXPOSE</a></li><li><a class="link lg:no-underline" href=#env>ENV</a></li><li><a class="link lg:no-underline" href=#add>ADD</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#source>Source</a></li><ul class=pl-2><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#destination>Destination</a></li><li><a class="link lg:no-underline" href=#add---keep-git-dir>ADD --keep-git-dir</a></li><li><a class="link lg:no-underline" href=#add---checksum>ADD --checksum</a></li><li><a class="link lg:no-underline" href=#add---chown---chmod>ADD --chown --chmod</a></li><li><a class="link lg:no-underline" href=#add---link>ADD --link</a></li><li><a class="link lg:no-underline" href=#add---exclude>ADD --exclude</a></li></ul><li><a class="link lg:no-underline" href=#copy>COPY</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#source-1>Source</a></li><ul class=pl-2><ul class=pl-2></ul></ul><li><a class="link lg:no-underline" href=#destination-1>Destination</a></li><li><a class="link lg:no-underline" href=#copy---from>COPY --from</a></li><li><a class="link lg:no-underline" href=#copy---chown---chmod>COPY --chown --chmod</a></li><li><a class="link lg:no-underline" href=#copy---link>COPY --link</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#copy---parents>COPY --parents</a></li><li><a class="link lg:no-underline" href=#copy---exclude>COPY --exclude</a></li></ul><li><a class="link lg:no-underline" href=#entrypoint>ENTRYPOINT</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#exec-form-entrypoint-example>Exec form ENTRYPOINT example</a></li><li><a class="link lg:no-underline" href=#shell-form-entrypoint-example>Shell form ENTRYPOINT example</a></li><li><a class="link lg:no-underline" href=#understand-how-cmd-and-entrypoint-interact>Understand how CMD and ENTRYPOINT interact</a></li></ul><li><a class="link lg:no-underline" href=#volume>VOLUME</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#notes-about-specifying-volumes>Notes about specifying volumes</a></li></ul><li><a class="link lg:no-underline" href=#user>USER</a></li><li><a class="link lg:no-underline" href=#workdir>WORKDIR</a></li><li><a class="link lg:no-underline" href=#arg>ARG</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#default-values>Default values</a></li><li><a class="link lg:no-underline" href=#scope>Scope</a></li><li><a class="link lg:no-underline" href=#using-arg-variables>Using ARG variables</a></li><li><a class="link lg:no-underline" href=#predefined-args>Predefined ARGs</a></li><li><a class="link lg:no-underline" href=#automatic-platform-args-in-the-global-scope>Automatic platform ARGs in the global scope</a></li><li><a class="link lg:no-underline" href=#buildkit-built-in-build-args>BuildKit built-in build args</a></li><ul class=pl-2></ul><li><a class="link lg:no-underline" href=#impact-on-build-caching>Impact on build caching</a></li></ul><li><a class="link lg:no-underline" href=#onbuild>ONBUILD</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#copy-or-mount-from-stage-image-or-context>Copy or mount from stage, image, or context</a></li><li><a class="link lg:no-underline" href=#onbuild-limitations>ONBUILD limitations</a></li></ul><li><a class="link lg:no-underline" href=#stopsignal>STOPSIGNAL</a></li><li><a class="link lg:no-underline" href=#healthcheck>HEALTHCHECK</a></li><li><a class="link lg:no-underline" href=#shell>SHELL</a></li><li><a class="link lg:no-underline" href=#here-documents>Here-Documents</a></li><ul class=pl-2><li><a class="link lg:no-underline" href=#example-running-a-multi-line-script>Example: Running a multi-line script</a></li><li><a class="link lg:no-underline" href=#example-creating-inline-files>Example: Creating inline files</a></li></ul><li><a class="link lg:no-underline" href=#dockerfile-examples>Dockerfile examples</a></li></ul></nav></div></div></aside></div></div></div></main><footer class=w-full><div class="flex justify-center py-20 px-4 bg-gray-light-100 dark:bg-gray-dark-200"><div class="flex w-full max-w-[840px] flex-col gap-10"><div class="flex flex-col md:flex-row gap-4 items-center justify-evenly"><a class="underline-offset-2 hover:underline" href=https://www.docker.com/>Product offerings</a> <a class="underline-offset-2 hover:underline" href=https://www.docker.com/pricing/>Pricing</a> <a class="underline-offset-2 hover:underline" href=https://www.docker.com/company/>About us</a> <a class="underline-offset-2 hover:underline" href=https://www.docker.com/support/>Support</a> <a class="underline-offset-2 hover:underline" href=https://docs.docker.com/contribute/>Contribute</a></div><hr class="text-divider-light dark:text-divider-dark"><div class="grid lg:grid-cols-3 place-items-center gap-8 grid-cols-1"><p class=text-sm>Copyright © 2013-2025 Docker Inc. All rights reserved.</p><div class="flex gap-4"><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title="X (Twitter)" href=http://twitter.com/docker/><svg viewBox="0 0 29 29"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M14.62 13.41l-3.3-4.62H9.56l4.09 5.72.51.72 3.51 4.91h1.76l-4.29-6.01-.52-.72z"/><path d="M14.5.0A14.5 14.5.0 1029 14.5 14.5 14.5.0 0014.5.0zm2.63 20.94-3.55-5.05-4.43 5.05H8l5.07-5.77L8 7.94h3.87l3.36 4.78 4.2-4.78h1.15l-4.84 5.51L21 20.94z"/></g></g></svg> </a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=LinkedIn href=https://www.linkedin.com/company/docker><svg viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zM8.176 9.66H5.174v9.035h3.002V9.66zm-3.18-2.795c0-.885.671-1.56 1.699-1.56 1.027.0 1.66.675 1.679 1.56.0.867-.652 1.562-1.7 1.562h-.018c-1.008.0-1.66-.695-1.66-1.562zm7.845 4.074c.398-.614 1.112-1.49 2.706-1.49 1.976.0 3.457 1.29 3.457 4.065v5.18h-3.002v-4.833c0-1.214-.435-2.043-1.522-2.043-.829.0-1.323.559-1.54 1.098-.08.194-.099.463-.099.733v5.046H9.838s.04-8.187.0-9.035h3.003v1.28z"/></svg> </a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=Instagram href=https://www.instagram.com/dockerinc/><svg viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zM6.984 4.774c.485-.19 1.04-.32 1.853-.359.814-.039 1.074-.048 3.148-.052 2.075-.004 2.335.004 3.15.04.812.035 1.368.164 1.853.352.503.193.93.454 1.355.878s.687.849.883 1.35c.19.486.32 1.041.359 1.854.038.815.048 1.074.052 3.148s-.005 2.335-.04 3.15c-.036.812-.164 1.368-.352 1.854a3.737 3.737.0 01-.878 1.354 3.746 3.746.0 01-1.35.884c-.486.19-1.04.32-1.853.358-.815.039-1.075.048-3.15.052-2.073.004-2.333-.004-3.148-.04-.813-.036-1.369-.163-1.854-.351a3.746 3.746.0 01-1.355-.878 3.74 3.74.0 01-.883-1.352c-.19-.485-.32-1.04-.359-1.852-.039-.815-.048-1.075-.052-3.15-.004-2.073.004-2.333.04-3.148.036-.813.163-1.368.351-1.855.195-.502.455-.929.879-1.354a3.736 3.736.0 011.35-.883zm.523 13.189c.27.103.674.227 1.419.26.806.034 1.047.042 3.086.038 2.04-.004 2.28-.012 3.086-.05.744-.036 1.148-.16 1.417-.266.357-.14.61-.306.877-.573.267-.268.432-.522.57-.879.104-.27.228-.674.26-1.419.035-.805.043-1.047.039-3.086-.004-2.039-.012-2.28-.05-3.086-.036-.744-.16-1.149-.266-1.417a2.366 2.366.0 00-.573-.878 2.364 2.364.0 00-.88-.57c-.269-.103-.674-.227-1.418-.26-.805-.034-1.047-.042-3.086-.038-2.04.004-2.28.012-3.086.05-.744.036-1.148.16-1.417.266a2.38 2.38.0 00-.878.573 2.37 2.37.0 00-.57.88c-.103.269-.227.674-.26 1.418-.034.805-.042 1.047-.038 3.086.004 2.04.013 2.28.05 3.086.035.744.161 1.148.266 1.418.14.356.305.61.573.877.268.266.522.431.88.57zm8.563-9.131a.917.917.0 11-.003-1.833.917.917.0 01.003 1.833zm-4.063 7.09a3.921 3.921.0 11-.015-7.843 3.921 3.921.0 01.015 7.842zm-.012-6.468a2.546 2.546.0 10.01 5.092 2.546 2.546.0 00-.01-5.092z"/></svg> </a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=YouTube href=http://www.youtube.com/user/dockerrun><svg viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zm7.543-15.79a1.971 1.971.0 00-1.392-1.39C16.923 6.49 12 6.49 12 6.49s-4.924.0-6.152.33A1.972 1.972.0 004.457 8.21c-.33 1.229-.33 3.79-.33 3.79s0 2.562.33 3.79c.18.677.714 1.21 1.391 1.391 1.228.329 6.151.329 6.151.329s4.923.0 6.15-.329a1.972 1.972.0 001.393-1.392c.329-1.227.329-3.789.329-3.789s0-2.561-.33-3.79zm-9.117 6.151L14.516 12l-4.09-2.361v4.722z"/></svg> </a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=Facebook href=https://www.facebook.com/docker.run><svg viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.54 24c5.948-.736 10.552-5.807 10.552-11.954C24.092 5.393 18.699.0 12.046.0S0 5.393.0 12.046c0 5.842 4.158 10.712 9.677 11.813v-8.374H6.538v-3.573h3.139V9.188c0-3.098 1.845-4.81 4.669-4.81 1.352.0 2.767.242 2.767.242v3.042h-1.559c-1.536.0-2.014.953-2.014 1.93v2.32h3.428l-.548 3.573h-2.88V24z"/></svg></a></div><div class="flex items-center gap-4"><a class="underline-offset-2 hover:underline" title="Docker Terms of Service" href=https://www.docker.com/legal/docker-terms-service>Terms of Service</a> <a class="underline-offset-2 hover:underline" title="Docker Systems Status Page" href=https://www.dockerstatus.com/>Status</a> <a class="underline-offset-2 hover:underline" title="Docker Legal Terms" href=https://www.docker.com/legal>Legal</a></div></div><div class="flex justify-between items-center"><button type=button id=ot-sdk-btn class=ot-sdk-show-settings> Cookies Settings</button><div class="flex items-center gap-2"><span>Theme:</span> <button aria-label="Theme switch" id=theme-switch class="rounded bg-blue-light px-4 py-1 text-white transition hover:bg-blue-light-400 dark:bg-blue-dark-400 dark:hover:bg-blue-dark" x-data="{ theme: localStorage.getItem('theme-preference') }" x-init="$watch('theme', value => { localStorage.setItem('theme-preference', value); document.firstElementChild.className = value; })" @click="theme = (theme === 'dark' ? 'light' : 'dark')"> <span class="icon-svg icon-sm dark:hidden">Light <svg width="48" height="48" viewBox="0 -960 960 960"><path d="M480-280q-83 0-141.5-58.5T280-480t58.5-141.5T480-680t141.5 58.5T680-480t-58.5 141.5T480-280zM70-450q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32Q57.25-510 70-510h1e2q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H70zm720 0q-12.75.0-21.37-8.68-8.63-8.67-8.63-21.5.0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h1e2q12.75.0 21.38 8.68 8.62 8.67 8.62 21.5.0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H790zM479.82-760q-12.82.0-21.32-8.63-8.5-8.62-8.5-21.37v-1e2q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v1e2q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63zm0 720Q467-40 458.5-48.63 450-57.25 450-70v-1e2q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82.0 21.32 8.62 8.5 8.63 8.5 21.38v1e2q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63zM240-678l-57-56q-9-9-8.63-21.6.37-12.61 8.53-21.5 8.89-8.9 21.5-8.9 12.6.0 21.6 9l56 57q8 9 8 21t-8 20.5-20.5 8.5-21.5-8zm494 495-56-57q-8-9-8-21.38.0-12.37 8.5-20.62 8.5-9 20.5-9t21 9l57 56q9 9 8.63 21.6-.37 12.61-8.53 21.5-8.89 8.9-21.5 8.9-12.6.0-21.6-9zm-56-495q-9-9-9-21t9-21l56-57q9-9 21.6-8.63 12.61.37 21.5 8.53 8.9 8.89 8.9 21.5.0 12.6-9 21.6l-57 56q-8 8-20.36 8-12.37.0-21.64-8zM182.9-182.9q-8.9-8.89-8.9-21.5.0-12.6 9-21.6l57-56q8.8-9 20.9-9 12.1.0 20.71 9 9.39 9 9.39 21t-9 21l-56 57q-9 9-21.6 8.63-12.61-.37-21.5-8.53z"/></svg></span> <span class="icon-svg icon-sm hidden dark:block">Dark<svg width="48" height="48" viewBox="0 -960 960 960"><path d="M480-120q-150 0-255-105T120-480q0-135 79.5-229T408-830q20-5 34-1t22 15q8 10 7.5 25t-8.5 35q-9 23-14 47t-5 49q0 90 63 153t153 63q25 0 48.5-4.5T754-461t38-7 26 9 13 23-2 36q-27 121-121 200.5T480-120z"/></svg></span></button></div></div></div></div></footer></body></html>