Skip to content

🐞 Slow Dockerfile builds after restoring runner snapshots #14749

Closed

Description

@stephoanie

What is the issue?

We use ephemeral Linux CI runners that restore /var/lib/docker from an EBS snapshot between runs. This preserves the Dagger engine container and its cache.
After upgrading from Dagger 0.20.6 to 0.21.10, we observed increased Dockerfile build and publication times despite successful snapshot restoration. We also observed occasional multi-minute engine startup spans, although detailed logs show that at least one was dominated by removing another engine version.
A Dockerfile change landed alongside the upgrade: we replaced cache-mount ownership options with an empty, nonroot-owned scratch stage used to seed a uv cache mount. We have not isolated these changes, so we cannot attribute the regression solely to the upgrade.

Environment

  • Dagger 0.21.10
  • Linux, amd64
  • Ephemeral runners with snapshot-backed EBS storage
  • /var/lib/docker restored before invoking Dagger
  • Multi-stage Dockerfiles built through Directory.dockerBuild, followed by Container.publish
  • uv dependency cache mounted during build steps

Dagger version

dagger v0.21.10 (image://registry.dagger.io/engine:v0.21.10) darwin/arm64/v8

Steps to reproduce

  1. On an ephemeral Linux/amd64 runner, build a multi-stage Dockerfile through Directory.dockerBuild, then publish the resulting container through Container.publish.

  2. Let the CI workflow complete. Near the end, an automated cleanup step stops running Dagger engine containers using:

   engines=$(docker ps --filter "name=dagger-engine-" -q)
if [ -n "$engines" ]; then
  docker stop -t 300 $engines
fi

A post-job action then snapshots the EBS volume containing /var/lib/docker.

  1. Start a fresh runner. Restore the snapshot, mount the restored volume at /var/lib/docker, and restart Docker before invoking Dagger.

  2. Invoke the same build/publication path. Logs confirm that Dagger starts the restored dagger-engine-v0.21.10 container.

  3. Record engine startup, engine connection, Directory.dockerBuild, and Container.publish durations separately.

  4. Repeat across subsequent runners restored from snapshots.

The upgrade from 0.20.6 to 0.21.10 coincided with this Dockerfile change:

# Previous cache mount:
RUN --mount=type=cache,target=/home/nonroot/.cache/uv,uid=65532 \
    uv sync ...

# Current cache seed stage:
FROM scratch AS uv-cache
USER 65532:65532
WORKDIR /uv

# In the dependency-build stage:
RUN --mount=type=cache,target=/home/nonroot/.cache/uv,from=uv-cache,source=/uv \
    uv sync ...

Log output

Abbreviated excerpts from an actual restored-snapshot run on 0.21.10. Timestamps and durations are retained; CI wrapper formatting and resource identifiers are removed.

2026-10-20T14:58:36Z RestoreSnapshot: Found latest snapshot [redacted]
2026-10-20T14:58:44Z RestoreSnapshot: Device [redacted] mounted to /var/lib/docker.
2026-10-20T14:59:04Z RestoreSnapshot: Docker service started.

2026-10-20T14:59:50Z exec docker start dagger-engine-v0.21.10 DONE [0.0s]
2026-10-20T14:59:50Z starting engine DONE [0.0s]
2026-10-20T14:59:52Z connecting to engine DONE [1.6s]

2026-10-20T15:00:34Z Directory.dockerBuild(...)
2026-10-20T15:03:50Z Directory.dockerBuild DONE [3m16s]
2026-10-20T15:04:49Z Container.publish DONE [58.1s]

Another restored-snapshot run showed:

2026-10-19T20:26:19Z exec docker start dagger-engine-v0.21.10 DONE [0.0s]
2026-10-19T20:26:22Z connecting to engine DONE [2.4s]
2026-10-19T20:32:07Z Directory.dockerBuild DONE [4m59s]
2026-10-19T20:32:28Z Container.publish DONE [21.1s]

Activity

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