Skip to content

Engine panics (nil CapSet) on RUN --mount=type=bind,…,rw in Directory.dockerBuild, then wipes its cache on restart #15198

Open

Description

@bsfelton

What is the issue?

Directory.dockerBuild on a Dockerfile containing a read-write bind mount (RUN --mount=type=bind,from=<stage>,…,rw) crashes the engine with a nil-pointer dereference. The client sees Error: Post "http://dagger/query": unexpected EOF.

On restart the engine logs dagql persistence store marked unclean; wiping and cold-starting and discards its entire cache. On a CI runner whose engine is shared by several projects, one such build wipes everyone's cache. We lost 89 GB this way before finding the cause.

The same Dockerfile without rw builds fine. docker buildx builds both.

Dagger version

dagger v0.21.11 (CLI and engine), linux/arm64/v8 engine on Docker Desktop (macOS) and linux/amd64 engine on a Debian VM (Docker, host socket). Both reproduce. Not yet tested on v0.21.12; its release notes don't mention it.

Notes

  • From the trace, dispatchRunMounts checks a capability (CapSet.Supports) that is only reached for this mount option, and Dagger's in-engine frontend calls it with a nil CapSet. Plain --mount=type=bind,from=… (read-only) does not reach it.
  • Two problems in one, which may deserve separate fixes. (1) A malformed or unsupported Dockerfile option can take down the whole engine instead of failing the call. (2) An unclean shutdown discards the full cache.
  • Workaround: copy from a read-only bind mount inside the same RUN:
    RUN --mount=type=bind,from=a,source=/d,target=/src cp -a /src /y && … && rm -rf /y

Dagger version

dagger v0.21.11

Steps to reproduce

Dockerfile:

FROM alpine:3.20 AS a
RUN mkdir /d && echo hi > /d/x
FROM alpine:3.20
RUN --mount=type=bind,from=a,source=/d,target=/y,rw cat /y/x
dagger core host directory --path=. docker-build sync

Removing ,rw makes it pass.

Log output

Client:

Error: Post "http://dagger/query": unexpected EOF
ERR cleanup failed msg="close dagger session" … dial unix /run/dagger/engine.sock: connect: connection refused

Engine:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x448a84]

goroutine 184838 [running]:
github.com/dagger/dagger/internal/buildkit/util/apicaps.(*CapSet).Supports(0x0, {0x25f35c5, 0x22})
	/app/internal/buildkit/util/apicaps/caps.go:109 +0xa4
github.com/dagger/dagger/internal/buildkit/frontend/dockerfile/dockerfile2llb.dispatchRunMounts(…)
	/app/internal/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go:104 +0x6f8
github.com/dagger/dagger/internal/buildkit/frontend/dockerfile/dockerfile2llb.dispatchRun(…)
	/app/internal/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:1230 +0xd78
github.com/dagger/dagger/internal/buildkit/frontend/dockerfile/dockerfile2llb.dispatch(…)
	/app/internal/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:912 +0x6f8
github.com/dagger/dagger/internal/buildkit/frontend/dockerfile/dockerfile2llb.toDispatchState(…)
	/app/internal/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:680 +0x2f28
github.com/dagger/dagger/internal/buildkit/frontend/dockerfile/dockerfile2llb.Dockerfile2LLB(…)
	/app/internal/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:89 +0x5c
github.com/dagger/dagger/core.(*Container).Build(…)
	/app/core/container.go:5312 +0xfa0
github.com/dagger/dagger/core/schema.(*directorySchema).dockerBuild(…)
	/app/core/schema/directory.go:1726 +0x710

After restart:

level=WARN msg="dagql persistence store marked unclean; wiping and cold-starting" cleanShutdown=0
level=WARN msg="local cache state invalid; resetting worker and dagql persistence state" reason=dagql_unclean_shutdown

Activity

  1. santhiprakash commented on Nov 18, 2026

    @santhiprakash

    Reproduced — the in-engine Dockerfile2LLB call leaves llbCaps nil (no dockerui.Client to source it from), and dispatchRunMounts calls Supports on it unguarded for any non-readonly bind mount. Opened #15206 with a nil-guard matching the other caps checks in the package, plus a unit test driving the same client-less ConvertOpt shape the engine uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions