Repository navigation
fix dockerfile bind mounts for files - #13273
Merged
Merged
Conversation
Dockerfile RUN --mount=type=bind can target either a directory or a single file. The LLB representation only gives us a bind source directory plus a selector, but the Dockerfile-to-Dagger conversion was eagerly resolving every non-root bind mount selector through Directory.directory. When the selector pointed at a regular file, container state cloning failed with "path /pyproject.toml is a file, not a directory" before the RUN could execute. Convert Dockerfile bind mounts through a hidden __withMountedPathDockerfileCompat container API instead. The converter now keeps the bind input as the base directory and passes the selector separately. During lazy evaluation, the core implementation stats that selected source path and materializes either a directory mount or a file mount, preserving the existing public withMountedDirectory/withMountedFile behavior. Add integration coverage for a Dockerfile bind-mounting pyproject.toml as a file and reading it during RUN. Verified with the focused run-mount-bind-file test and the broader run-mount-bind Dockerfile integration coverage. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
dockerfile-mount-fix
branch
from
May 29, 2026 20:35
d39fd2b to
89e83a4
Compare
Signed-off-by: Erik Sipsma <[email protected]>
tiborvass
approved these changes
May 29, 2026
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
dagger 0.21.1 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## v0.21.1 - 2026-05-29 ### Added - Add native GraphQL interfaces and unified object IDs in DagQL by @vito in dagger/dagger#12041 \ Dagger now exposes objects through the standard `Node` interface and `ID` scalar, enabling APIs to accept generic Dagger objects while preserving SDK compatibility through legacy `FooID` and `loadFooFromID` views for older clients. ### Fixed - Python SDK: fix unhandled module registration cases and bugs by removing the AST-based module analyzer and returning to runtime introspection by @eunomie in dagger/dagger#13251 - Fix Go module generation to avoid unnecessary dependency churn in generated `go.mod` and `go.sum` files by @sipsma in dagger/dagger#13244 - Fix registry authentication so `withRegistryAuth` credentials are not incorrectly skipped and authenticated publishes keep working after anonymous pulls to the same registry by @marcosnils + @sipsma in dagger/dagger#13255 dagger/dagger#13256 - Fix published image layer structure so `withDirectory` and `withFile` operations preserve expected layer boundaries instead of being squashed into a few large layers by @sipsma in dagger/dagger#13242 - Fix Dockerfile `RUN --mount=type=bind` conversion when the bind source selector points to a regular file, improving compatibility with file and directory bind mounts by @sipsma in dagger/dagger#13273 - Fix module source cache dependency retention, including ephemeral `missing shared result` errors after cache persistence or engine restarts by @sipsma in dagger/dagger#13243 - Fix a bug where some cache entries did not have their size calculated during background and shutdown pruning by @sipsma in dagger/dagger#13225 - Fix repeated `op://` 1Password secret reads by caching resolved 1Password secret values during a run, avoiding provider rate limits when the same secret is mounted or read multiple times by @matipan in dagger/dagger#13249 - Fix Windows Changeset exports so `RemovePaths` entries cannot remove files outside the selected export root through backslash or absolute-path interpretation by @marcosnils in dagger/dagger#13222 - Fix `dagger --x-release` for tagged releases so semver refs download release artifacts instead of looking in the main-build artifact namespace, and prevent local runner override environment from leaking into the re-executed CLI by @grouville in dagger/dagger#13259 ### What to do next? - Read the [documentation](https://docs.dagger.io) - Join our [Discord server](https://discord.gg/dagger-io) - Follow us on [Twitter](https://twitter.com/dagger_io) </pre> <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.1">https://github.com/dagger/dagger/releases/tag/v0.21.1</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!9585
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Fix Dockerfile RUN --mount=type=bind conversion when the bind source selector points at a regular file instead of a directory.
The LLB representation gives us a bind input plus a selector, but it does not statically identify whether that selector is a file or directory. The previous conversion eagerly resolved every non-root bind selector with Directory.directory(path: ...), then mounted it with withMountedDirectory. That worked for directory bind mounts, but a Dockerfile such as:
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml ...failed during container state cloning with:
Fix
Add an internal Dockerfile-compat container mount path that preserves the LLB source directory and selector separately. During lazy evaluation, the core implementation stats the selected source path and materializes either a directory mount or a file mount.
This keeps the public withMountedDirectory and withMountedFile APIs unchanged while allowing Dockerfile bind mounts to match BuildKit behavior for both files and directories.
Tests
Added coverage for binding pyproject.toml as a file in a Dockerfile RUN --mount.
Validated with:
dagger --progress=plain call engine-dev test --pkg ./core/integration --run=TestDockerfile/TestDockerBuild/run-mount-bind-filedagger --progress=plain call engine-dev test --pkg ./core/integration --run=TestDockerfile/TestDockerBuild/run-mount-bind