Repository navigation
dockerfile: don't nil-deref llbCaps on read-write bind mounts - #15206
Open
santhiprakash wants to merge 1 commit into
Open
santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
The engine's dockerBuild path calls Dockerfile2LLB without a dockerui Client, so opt.LLBCaps is never populated and dispatchOpt.llbCaps stays nil. dispatchRunMounts then called llbCaps.Supports() unconditionally for any non-readonly bind mount, panicking on a nil receiver. Guard the check like the sibling llbCaps checks in convert.go: with unknown caps the mount keeps its output instead of applying ForceNoOutput. Signed-off-by: Santhi Prakash <[email protected]>
santhiprakash
force-pushed
the
fix-dockerbuild-rw-bind-mount-nil-caps
branch
from
November 18, 2026 11:49
5fcbbef to
461c6bf
Compare
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.
Fixes #15198
Problem
Directory.dockerBuildon a Dockerfile with a read-write bind mount(
RUN --mount=type=bind,from=<stage>,...,rw) panics the engine:The client just sees
unexpected EOF, and on restart the engine reportsdagql persistence store marked unclean; wiping and cold-starting, losingits cache. Read-only bind mounts are unaffected — only
rwreaches thebuggy call.
Root cause
dockerBuildincore/container.gobuildsdockerfile2llb.ConvertOptwith neither
ClientnorLLBCapsset.toDispatchStateonly fillsopt.LLBCapsfromopt.Client.BuildOpts().LLBCapswhenopt.Client != nil, so on the in-engine pathdispatchOpt.llbCapsis nil — anddispatchRunMountscalledopt.llbCaps.Supports(...)unguarded for anynon-readonly bind mount.
Nil
llbCapsis an expected state on this path:toDispatchStatealreadyskips
llb.WithCapswhenopt.LLBCaps == nil, and every other caps checkin the package is nil-guarded (
convert.go— including one that comments// cfg.opt.llbCaps can be nil in unit tests). This was the onlyunguarded site.
Fix
Nil-guard the
Supportscall like its siblings: when caps are unknown,skip
llb.ForceNoOutputand let the mount keep its output. The mountstill works;
ForceNoOutputis only the no-output optimization forwritable bind mounts.
Callers that do advertise caps (buildkit's dockerui path) keep the exact
same behavior as before.
Verification
New
internal/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount_test.go:TestDockerfile2LLBBindMountRWWithoutLLBCapsdrivesDockerfile2LLBwith
ConvertOpt{}(no Client/LLBCaps — the engine's shape) on aDockerfile with
RUN --mount=type=bind,from=a,source=/d,target=/y,rw.Before the fix it panics at the exact stack above
(
caps.go:109 <- convert_runmount.go:104 <- dispatchRun <- Dockerfile2LLB);after, it produces a
BINDmount at/ythat is not readonly and keepsits output (
Output != pb.SkipOutput).TestDockerfile2LLBBindMountRWWithLLBCapsadvertisesCapExecMountBindReadWriteNoOutputand assertsForceNoOutputstillapplies (
Output == pb.SkipOutput), so the guard does not disable theoptimization when caps are known.
Run on this host:
plus
gofmt,go vet, andgo buildon the touched package. Therepo-native
dagger api call engine-dev testintegration path needs aDocker engine, which this host doesn't have; the reporter's engine-level
repro should be covered by the new test's direct
Dockerfile2LLBcall.Risks
The only behavioral delta is in the nil-caps path (in-engine
dockerBuild, or any caller invokingDockerfile2LLBwithout adockerui.Client): a read-write bind mount there keeps its output ratherthan crashing. With caps advertised, output is unchanged.