Skip to content

daemon/containerd: Keep lazy pulls lazy for remote snapshotters - #53877

Merged
vvoland merged 1 commit into
moby:masterfrom
vvoland:fix-lazy-pull
Oct 7, 2026
Merged

vvoland merged 1 commit into
moby:masterfrom
vvoland:fix-lazy-pull

Conversation

@vvoland

@vvoland vvoland commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Pulls always fetched every layer blob, even when a remote snapshotter such as stargz prepared the layers lazily, which removed the download savings of lazy pulling.

Skip fetching all layer content when pulling into a known remote snapshotter (nydus, overlaybd, soci, stargz). The "lazy-pull" feature overrides this in either direction.

Lazily pulled images may lack layer blobs, so saving or pushing them can fail.

Note, this effectively unfixes #53864 for remote snapshotters - however, I considerer this an expected trade-off of lazy pulling for now.

Release notes (optional)

containerd image store: Add the `lazy-pull` daemon feature to control whether `docker pull` skips downloading layer content that the snapshotter already provides. Lazy pulls are enabled by default for known remote snapshotters (`nydus`, `overlaybd`, `soci`, `stargz`).
containerd image store: Fix a regression in v29.9.0-rc.1 where `docker pull` downloaded all layer content when using a remote snapshotter such as stargz.

A picture of a cute animal (not mandatory but encouraged)

Pulls always fetched every layer blob, even when a remote snapshotter
such as stargz prepared the layers lazily, which removed the download
savings of lazy pulling.

Skip fetching all layer content when pulling into a known remote
snapshotter (nydus, overlaybd, soci, stargz). The "lazy-pull" feature
overrides this in either direction.

Lazily pulled images may lack layer blobs, so saving or pushing them
can fail.

Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland vvoland added this to the 29.9.0 milestone Oct 7, 2026
@vvoland vvoland self-assigned this Oct 7, 2026
@vvoland vvoland added the kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. label Oct 7, 2026
@github-actions github-actions Bot added area/daemon Core Engine containerd-integration Issues and PRs related to containerd integration labels Oct 7, 2026
@vvoland
vvoland requested review from thaJeztah and a balanced review from Copilot October 7, 2026 16:29
@vvoland vvoland added area/images Image Service and removed area/daemon Core Engine labels Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented behavior and adequately tests the selection logic.

0 open findings

What changed in this PR

Adds configurable lazy pulling for the containerd image store, preserving remote snapshotter download savings while retaining complete pulls elsewhere.

Changes:

  • Defaults lazy pulls for known remote snapshotters.
  • Adds a reload-aware lazy-pull feature override.
  • Tests default and overridden behavior.
File Description
daemon/​daemon.go Supplies feature flags to the image service.
daemon/​containerd/​service.go Adds the feature-provider interface.
daemon/​containerd/​image_pull.go Conditionally fetches all layer content.
daemon/​containerd/​image_pull_test.go Tests lazy-pull selection.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vvoland

vvoland commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Docs follow up: docker/docs#26307

}

var knownRemoteSnapshotters = map[string]struct{}{
"nydus": {},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look if the snapshotter itself could somehow advertise this (not for this PR); I was wondering if there already was something like that.

type featuresProvider interface {
// Features returns the current feature flags, which can change when the
// daemon configuration is reloaded.
Features() map[string]bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need synchronization around this, or good as is?

We could change it for the function to take the name of the feature looked for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, never mind; this is something we already had, just an interface

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need as it's not mutated after it's set.

And reload doesn't mutate the live map either. The config is deep copied as a whole and then replaced and published as new.

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vvoland
vvoland merged commit 6036f99 into moby:master Oct 7, 2026
273 of 286 checks passed
@vvoland
vvoland deleted the fix-lazy-pull branch October 7, 2026 17:09
ethanjli added a commit to openUC2/os-rpi that referenced this pull request Nov 19, 2026
(This PR completely rewritten by Ethan)

## Expanded description PR

This PR works around a non-version-controlled regression in the size of
the OS image which was introduced by Docker Engine 29.9.0, resulting in
images being ~8.5 GB with moderate compression. Specifically, this PR
runs `docker pull` in lazy-pull mode (described further below). The
result is that SD card images are now only ~3.5 GB with moderate
compression, and first boot takes a bit longer.

This PR also fixes a regression which was introduced by
00c612b, which resulted in the `pi`
user's shell being set by default to `/usr/sbin/nologin` instead of
`/usr/bin/bash` due to a behavior change in the underlying Raspberry Pi
OS.

This work is tracked on Notion at
https://app.notion.com/p/Troubleshoot-huge-regression-in-OS-image-file-size-4164e612c78a80da80f9c29455cb2e2b
.

## Bene's Original PR description

### Why

Since 2026-10-08 the `.img.xz` grew from ~5.90 GB to ~8.55 GB, also for
rebuilds of older commits.

Cause: `os-build/docker/install.sh` installs unpinned Docker. Docker
Engine 29.9.0 (released 2026-10-08, containerd 2.4.1) fixed "pulls
skipping required layer blobs when unpacked layers already exist"
(moby/moby#53615). Our build does `docker image load` from the
pre-downloaded tarballs, then `forklift stage set-next` pulls the same
images again. Up to 29.8.2 that pull skipped the blobs (1 s). From
29.9.0 it downloads all compressed layers (22 s) into containerd's
content store.

Evidence from run logs (#37624957554 small vs #38280313540 large):
- only apt diffs: docker-ce 29.8.2→29.9.0, containerd.io 2.3.6→2.4.1,
tailscale
- rootfs after PiShrink: 16.70 → 19.40 GB (+2.71 GB); compressed layers
of the 11 images: 2.68 GB
- action SHAs, base image, PiShrink version all identical

### Change

Write `/etc/docker/daemon.json` with `{"features": {"lazy-pull": true}}`
before Docker is installed. `lazy-pull` (moby/moby#53877, new in 29.9.0)
controls whether `docker pull` skips layer content the snapshotter
already provides; by default it's only on for remote snapshotters.

### To verify

- The CI artifact for this PR should be ~5.9 GB instead of ~8.55 GB.
- In the build log, the forklift re-pull of the 11 images should take ~1
s again, with no `Write failed … locked` errors.

Note: like pre-Oct-8 images, the loaded images will be "runnable but
incomplete" (no compressed blobs), so `docker save`/`docker push` of
them on a device won't work.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ethan Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Service containerd-integration Issues and PRs related to containerd integration impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[29.9.0-rc.1 regression] docker pull fetches all layer blobs with stargz

3 participants