{
    "api_version": "1",
    "kind": "dse_post",
    "self": "https://update.dsesecurity.com/api/v1/posts/write-docker-build-artifacts-outside-temporary-bind-mounts/",
    "item": {
        "id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
        "slug": "write-docker-build-artifacts-outside-temporary-bind-mounts",
        "url": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
        "alternate_urls": {
            "markdown": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts.md",
            "json": "https://update.dsesecurity.com/api/v1/posts/write-docker-build-artifacts-outside-temporary-bind-mounts/"
        },
        "title": "Write Docker build artifacts outside temporary bind mounts",
        "summary": "Docker build bind mounts last for a RUN instruction, and writes inside them are discarded afterward even with rw. Put the intended generated artifact outside the mounted target.",
        "format": {
            "slug": "guide",
            "name": "Guide"
        },
        "priority": {
            "slug": "advisory",
            "name": "Advisory"
        },
        "featured": false,
        "image": {
            "theme": "managed-it",
            "label": "Managed IT operations",
            "alt": "A controlled technology lifecycle progressing from assessment to approved production.",
            "card_url": "https://update.dsesecurity.com/assets/editorial/managed-it-card.webp?v=1.8.20",
            "hero_url": "https://update.dsesecurity.com/assets/editorial/managed-it-hero.webp?v=1.8.20",
            "social_url": "https://update.dsesecurity.com/assets/editorial/managed-it-social-v2.jpg?v=1.8.20",
            "width": 2400,
            "height": 1350
        },
        "topics": [
            {
                "slug": "it",
                "name": "IT",
                "url": "https://update.dsesecurity.com/topic/it/"
            }
        ],
        "author": {
            "name": "DSE Security Editorial Team",
            "url": "https://update.dsesecurity.com/#editorial-team",
            "type": "Organization"
        },
        "publisher": {
            "name": "Detection Systems & Engineering",
            "url": "https://dsesecurity.com/"
        },
        "published_at": "2026-10-29T17:40:50+00:00",
        "modified_at": "2026-10-29T17:41:39+00:00",
        "reviewed_on": "2026-10-29",
        "reading_minutes": 3,
        "word_count": 533,
        "potentially_affected": "Review scope: temporary bind mounts used by Dockerfile RUN in Docker's cache-optimization guide; runtime bind mounts and final filesystem-export selection are separate reviews.",
        "dse_recommendation": "Map the temporary input mount and persistent build-output path before changing the instruction, then inspect the artifact after the mount ends.",
        "primary_source": {
            "name": "Docker Docs — Optimize cache usage in builds",
            "url": "https://docs.docker.com/build/cache/optimize/",
            "published_on": null,
            "authority": "docs.docker.com"
        },
        "publishing_principles": "https://update.dsesecurity.com/updates/dse-updates-editorial-methodology/",
        "usage_info": "https://update.dsesecurity.com/usage/",
        "copyright_notice": "Copyright © 2026 Detection Systems & Engineering. All rights reserved.",
        "content_html": "<p><strong>Bottom line:</strong> Decide where the generated artifact must survive before introducing a temporary build mount. Keep the mounted input path and intended output path visibly separate in the Dockerfile review and in the proposed verification.</p>\n<h2>Source fact: documented behavior</h2>\n<p>The <a href=\"https://docs.docker.com/build/cache/optimize/\" target=\"_blank\" rel=\"noopener noreferrer\">Optimize cache usage in builds</a> documentation is the primary reference.</p>\n<p>The documented build bind mount exposes source files only for the <code>RUN</code> instruction; the example writes its generated artifact outside the mounted target. Build bind mounts are read-only by default, and adding <code>rw</code> does not preserve writes inside the mount after the instruction ends. A build mount temporarily hides existing contents of its target directory; those original contents return after the <code>RUN</code> instruction.</p>\n<h2>What the source does not establish</h2>\n<p>This article concerns temporary build inputs and output placement. It does not change the runtime bind-mount review, choose which final-stage files should be exported or prove that a generated executable works. Treat application acceptance, packaging and host-path access as separate requirements.</p>\n<h2>Applicability questions</h2>\n<ul>\n<li>Which directory is the temporary input target?</li>\n<li>Where should the generated artifact remain after the instruction?</li>\n<li>Does the proposal write inside the mounted directory?</li>\n<li>Could existing target contents complicate what the build instruction sees?</li>\n</ul>\n<h2>DSE recommendation: mark the input and output paths explicitly</h2>\n<p>DSE recommends annotating the proposed build instruction with three paths: source input, temporary mount target and generated output. Have the build owner identify the required surviving file before changing the mount. Use the actual tool&#8217;s output configuration rather than assuming that its default output directory is suitable.</p>\n<p>Compare the output path with the mount boundary. If the proposal enables writing inside the input mount, require a reason and keep that decision distinct from the artifact-retention requirement. Do not treat a writable mount option as a retention fix. Keep the intended surviving output at a reviewed location outside that temporary input target.</p>\n<p>Inspect any pre-existing files at the target as part of the design review. Record which view the build step should consume and which files should be visible afterward. Avoid putting unrelated generated files and source inputs under one ambiguous path merely to shorten the command.</p>\n<p>Reconcile artifact creation with later packaging in a separate step. Identify the next instruction that consumes the generated file and the intended final deliverable. Keep the temporary-mount test focused on whether the required output survived its instruction; use the existing exporter or runtime-dependency procedure for later acceptance. Preserve failures without changing several path decisions at once.</p>\n<h2>Verification and evidence</h2>\n<p>Proposed verification, not performed: use a disposable build context with harmless marker inputs. Create one controlled case that attempts a write under the temporary mount and another that writes the intended output outside it. Predict which files should remain after each instruction before inspecting the actual next-stage view.</p>\n<p>Add a separate case with a harmless existing file beneath the target to inspect the mounted and restored views. Keep all locations confined to the disposable build. Retain the Dockerfile, mount options, output configuration and actual file observations. Check the generated artifact&#8217;s application behavior only through its separate approved acceptance plan.</p>\n<h2>Official references</h2>\n<ul>\n<li><a href=\"https://docs.docker.com/build/cache/optimize/\" target=\"_blank\" rel=\"noopener noreferrer\">Optimize cache usage in builds</a> — Docker Docs.</li>\n</ul>\n<p>Source review completed October 29, 2026. Recheck the official documentation and deployment-specific applicability before a production change.</p>\n",
        "content_text": "Bottom line: Decide where the generated artifact must survive before introducing a temporary build mount. Keep the mounted input path and intended output path visibly separate in the Dockerfile review and in the proposed verification.\nSource fact: documented behavior\nThe Optimize cache usage in builds documentation is the primary reference.\nThe documented build bind mount exposes source files only for the RUN instruction; the example writes its generated artifact outside the mounted target. Build bind mounts are read-only by default, and adding rw does not preserve writes inside the mount after the instruction ends. A build mount temporarily hides existing contents of its target directory; those original contents return after the RUN instruction.\nWhat the source does not establish\nThis article concerns temporary build inputs and output placement. It does not change the runtime bind-mount review, choose which final-stage files should be exported or prove that a generated executable works. Treat application acceptance, packaging and host-path access as separate requirements.\nApplicability questions\n\nWhich directory is the temporary input target?\nWhere should the generated artifact remain after the instruction?\nDoes the proposal write inside the mounted directory?\nCould existing target contents complicate what the build instruction sees?\n\nDSE recommendation: mark the input and output paths explicitly\nDSE recommends annotating the proposed build instruction with three paths: source input, temporary mount target and generated output. Have the build owner identify the required surviving file before changing the mount. Use the actual tool’s output configuration rather than assuming that its default output directory is suitable.\nCompare the output path with the mount boundary. If the proposal enables writing inside the input mount, require a reason and keep that decision distinct from the artifact-retention requirement. Do not treat a writable mount option as a retention fix. Keep the intended surviving output at a reviewed location outside that temporary input target.\nInspect any pre-existing files at the target as part of the design review. Record which view the build step should consume and which files should be visible afterward. Avoid putting unrelated generated files and source inputs under one ambiguous path merely to shorten the command.\nReconcile artifact creation with later packaging in a separate step. Identify the next instruction that consumes the generated file and the intended final deliverable. Keep the temporary-mount test focused on whether the required output survived its instruction; use the existing exporter or runtime-dependency procedure for later acceptance. Preserve failures without changing several path decisions at once.\nVerification and evidence\nProposed verification, not performed: use a disposable build context with harmless marker inputs. Create one controlled case that attempts a write under the temporary mount and another that writes the intended output outside it. Predict which files should remain after each instruction before inspecting the actual next-stage view.\nAdd a separate case with a harmless existing file beneath the target to inspect the mounted and restored views. Keep all locations confined to the disposable build. Retain the Dockerfile, mount options, output configuration and actual file observations. Check the generated artifact’s application behavior only through its separate approved acceptance plan.\nOfficial references\n\nOptimize cache usage in builds — Docker Docs.\n\nSource review completed October 29, 2026. Recheck the official documentation and deployment-specific applicability before a production change.",
        "content_markdown": "Bottom line: Decide where the generated artifact must survive before introducing a temporary build mount. Keep the mounted input path and intended output path visibly separate in the Dockerfile review and in the proposed verification.\n\n## Source fact: documented behavior\n\nThe [Optimize cache usage in builds](https://docs.docker.com/build/cache/optimize/) documentation is the primary reference.\n\nThe documented build bind mount exposes source files only for the RUN instruction; the example writes its generated artifact outside the mounted target. Build bind mounts are read-only by default, and adding rw does not preserve writes inside the mount after the instruction ends. A build mount temporarily hides existing contents of its target directory; those original contents return after the RUN instruction.\n\n## What the source does not establish\n\nThis article concerns temporary build inputs and output placement. It does not change the runtime bind-mount review, choose which final-stage files should be exported or prove that a generated executable works. Treat application acceptance, packaging and host-path access as separate requirements.\n\n## Applicability questions\n\n- Which directory is the temporary input target?\n\n- Where should the generated artifact remain after the instruction?\n\n- Does the proposal write inside the mounted directory?\n\n- Could existing target contents complicate what the build instruction sees?\n\n## DSE recommendation: mark the input and output paths explicitly\n\nDSE recommends annotating the proposed build instruction with three paths: source input, temporary mount target and generated output. Have the build owner identify the required surviving file before changing the mount. Use the actual tool’s output configuration rather than assuming that its default output directory is suitable.\n\nCompare the output path with the mount boundary. If the proposal enables writing inside the input mount, require a reason and keep that decision distinct from the artifact-retention requirement. Do not treat a writable mount option as a retention fix. Keep the intended surviving output at a reviewed location outside that temporary input target.\n\nInspect any pre-existing files at the target as part of the design review. Record which view the build step should consume and which files should be visible afterward. Avoid putting unrelated generated files and source inputs under one ambiguous path merely to shorten the command.\n\nReconcile artifact creation with later packaging in a separate step. Identify the next instruction that consumes the generated file and the intended final deliverable. Keep the temporary-mount test focused on whether the required output survived its instruction; use the existing exporter or runtime-dependency procedure for later acceptance. Preserve failures without changing several path decisions at once.\n\n## Verification and evidence\n\nProposed verification, not performed: use a disposable build context with harmless marker inputs. Create one controlled case that attempts a write under the temporary mount and another that writes the intended output outside it. Predict which files should remain after each instruction before inspecting the actual next-stage view.\n\nAdd a separate case with a harmless existing file beneath the target to inspect the mounted and restored views. Keep all locations confined to the disposable build. Retain the Dockerfile, mount options, output configuration and actual file observations. Check the generated artifact’s application behavior only through its separate approved acceptance plan.\n\n## Official references\n\n- [Optimize cache usage in builds](https://docs.docker.com/build/cache/optimize/) — Docker Docs.\n\nSource review completed October 29, 2026. Recheck the official documentation and deployment-specific applicability before a production change."
    },
    "json_ld": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://dsesecurity.com/#organization",
                "name": "Detection Systems & Engineering",
                "alternateName": "DSE Security",
                "url": "https://dsesecurity.com/",
                "logo": {
                    "@type": "ImageObject",
                    "url": "https://update.dsesecurity.com/assets/dse-logo-20260812.png?v=1.8.20"
                }
            },
            {
                "@type": "Organization",
                "@id": "https://update.dsesecurity.com/#editorial-team",
                "name": "DSE Security Editorial Team",
                "url": "https://update.dsesecurity.com/",
                "parentOrganization": {
                    "@id": "https://dsesecurity.com/#organization"
                }
            },
            {
                "@type": "WebSite",
                "@id": "https://update.dsesecurity.com/#website",
                "name": "DSE Updates",
                "alternateName": "DSE Security Knowledge Hub",
                "url": "https://update.dsesecurity.com/",
                "inLanguage": "en-US",
                "publisher": {
                    "@id": "https://dsesecurity.com/#organization"
                },
                "potentialAction": {
                    "@type": "SearchAction",
                    "target": {
                        "@type": "EntryPoint",
                        "urlTemplate": "https://update.dsesecurity.com/?q={search_term_string}"
                    },
                    "query-input": "required name=search_term_string"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
                "url": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
                "isPartOf": {
                    "@id": "https://update.dsesecurity.com/#website"
                },
                "lastReviewed": "2026-10-29"
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/#breadcrumbs",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "DSE Updates",
                        "item": "https://update.dsesecurity.com/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "IT",
                        "item": "https://update.dsesecurity.com/topic/it/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 3,
                        "name": "Write Docker build artifacts outside temporary bind mounts",
                        "item": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/"
                    }
                ]
            },
            {
                "@type": [
                    "Article",
                    "TechArticle"
                ],
                "@id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/#article",
                "identifier": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
                "url": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/",
                "headline": "Write Docker build artifacts outside temporary bind mounts",
                "description": "Docker build bind mounts last for a RUN instruction, and writes inside them are discarded afterward even with rw.",
                "abstract": "Docker build bind mounts last for a RUN instruction, and writes inside them are discarded afterward even with rw. Put the intended generated artifact outside the mounted target.",
                "articleBody": "Bottom line: Decide where the generated artifact must survive before introducing a temporary build mount. Keep the mounted input path and intended output path visibly separate in the Dockerfile review and in the proposed verification.\nSource fact: documented behavior\nThe Optimize cache usage in builds documentation is the primary reference.\nThe documented build bind mount exposes source files only for the RUN instruction; the example writes its generated artifact outside the mounted target. Build bind mounts are read-only by default, and adding rw does not preserve writes inside the mount after the instruction ends. A build mount temporarily hides existing contents of its target directory; those original contents return after the RUN instruction.\nWhat the source does not establish\nThis article concerns temporary build inputs and output placement. It does not change the runtime bind-mount review, choose which final-stage files should be exported or prove that a generated executable works. Treat application acceptance, packaging and host-path access as separate requirements.\nApplicability questions\n\nWhich directory is the temporary input target?\nWhere should the generated artifact remain after the instruction?\nDoes the proposal write inside the mounted directory?\nCould existing target contents complicate what the build instruction sees?\n\nDSE recommendation: mark the input and output paths explicitly\nDSE recommends annotating the proposed build instruction with three paths: source input, temporary mount target and generated output. Have the build owner identify the required surviving file before changing the mount. Use the actual tool’s output configuration rather than assuming that its default output directory is suitable.\nCompare the output path with the mount boundary. If the proposal enables writing inside the input mount, require a reason and keep that decision distinct from the artifact-retention requirement. Do not treat a writable mount option as a retention fix. Keep the intended surviving output at a reviewed location outside that temporary input target.\nInspect any pre-existing files at the target as part of the design review. Record which view the build step should consume and which files should be visible afterward. Avoid putting unrelated generated files and source inputs under one ambiguous path merely to shorten the command.\nReconcile artifact creation with later packaging in a separate step. Identify the next instruction that consumes the generated file and the intended final deliverable. Keep the temporary-mount test focused on whether the required output survived its instruction; use the existing exporter or runtime-dependency procedure for later acceptance. Preserve failures without changing several path decisions at once.\nVerification and evidence\nProposed verification, not performed: use a disposable build context with harmless marker inputs. Create one controlled case that attempts a write under the temporary mount and another that writes the intended output outside it. Predict which files should remain after each instruction before inspecting the actual next-stage view.\nAdd a separate case with a harmless existing file beneath the target to inspect the mounted and restored views. Keep all locations confined to the disposable build. Retain the Dockerfile, mount options, output configuration and actual file observations. Check the generated artifact’s application behavior only through its separate approved acceptance plan.\nOfficial references\n\nOptimize cache usage in builds — Docker Docs.\n\nSource review completed October 29, 2026. Recheck the official documentation and deployment-specific applicability before a production change.",
                "datePublished": "2026-10-29T17:40:50+00:00",
                "dateModified": "2026-10-29T17:41:39+00:00",
                "mainEntityOfPage": {
                    "@id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/"
                },
                "inLanguage": "en-US",
                "isAccessibleForFree": true,
                "author": {
                    "@type": "Organization",
                    "name": "DSE Security Editorial Team",
                    "url": "https://update.dsesecurity.com/#editorial-team"
                },
                "publisher": {
                    "@id": "https://dsesecurity.com/#organization"
                },
                "image": {
                    "@type": "ImageObject",
                    "@id": "https://update.dsesecurity.com/updates/write-docker-build-artifacts-outside-temporary-bind-mounts/#primaryimage",
                    "url": "https://update.dsesecurity.com/assets/editorial/managed-it-social-v2.jpg?v=1.8.20",
                    "contentUrl": "https://update.dsesecurity.com/assets/editorial/managed-it-social-v2.jpg?v=1.8.20",
                    "width": 1200,
                    "height": 630,
                    "caption": "Write Docker build artifacts outside temporary bind mounts"
                },
                "articleSection": [
                    "IT"
                ],
                "keywords": [
                    "IT",
                    "Guide",
                    "Advisory priority"
                ],
                "genre": "Guide",
                "about": [
                    {
                        "@type": "Thing",
                        "name": "IT",
                        "url": "https://update.dsesecurity.com/topic/it/"
                    }
                ],
                "wordCount": 533,
                "timeRequired": "PT3M",
                "publishingPrinciples": "https://update.dsesecurity.com/updates/dse-updates-editorial-methodology/",
                "usageInfo": "https://update.dsesecurity.com/usage/",
                "copyrightHolder": {
                    "@id": "https://dsesecurity.com/#organization"
                },
                "copyrightNotice": "Copyright © 2026 Detection Systems & Engineering. All rights reserved.",
                "citation": {
                    "@type": "CreativeWork",
                    "name": "Docker Docs — Optimize cache usage in builds",
                    "url": "https://docs.docker.com/build/cache/optimize/"
                }
            }
        ]
    }
}