Docker Build cache backends: export and import an external cache
Answer: Cache backends let you manage your build cache externally, which becomes almost essential in CI/CD build environments.
Why an external cache
These backends let you keep build cache outside the builder.
BuildKit still stores results internally, and it can also export that cache so a later build can import it.
CI and CD runs often have little or no persistence, but builds still need to stay short, so an external cache is almost essential.
Backends, drivers, and flags
The default docker driver supports the inline, local, registry, and gha backends, but only if the containerd image store is enabled.
Other cache backends require a different builder driver.
If you use secrets or credentials in a build, pass them with the dedicated --secret option; copying them with COPY or ARG can leak them into the cache.
The inline backend embeds the build cache in the image and pushes it to the same place as the main output, and it only works with the image exporter.
The registry backend embeds the cache in a separate image and pushes it to a dedicated location.
The local backend writes the cache to a local directory.
The gha, s3, and azblob backends upload the cache to GitHub Actions, S3, or Azure Blob Storage.
Export a cache with --cache-to, then import it on a later build with --cache-from.
Unlike the local BuildKit cache, which is always on, these storage backends have to be selected explicitly.
See also
Claims
- id: C1 claim: An external cache is almost essential in CI and CD, where builders often do not persist. source: S1 evidence: "An external cache becomes almost essential in CI/CD build environments."
- id: C2 claim: The default docker driver supports inline, local, registry, and gha only with the containerd image store enabled. source: S1 evidence: "The default docker driver supports the inline"
- id: C3 claim: Export cache with --cache-to and import it later with --cache-from. source: S2 evidence: "to export the cache to your storage backend of choice."
Sources
- [S1] Cache backends. Docker, Inc.. https://docs.docker.com/build/cache/backends/ . License: Apache License 2.0. Accessed 2026-11-26.
- [S2] Cache backends (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/cache/backends/_index.md . License: Apache License 2.0. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Cache backends; Docker, Inc., Cache backends (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Cache backends; Docker, Inc., Cache backends (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Docker Build cache backends: export and import an external cache." iinventedlight Library, iil:note:m2ky6wj7, version of 2026-11-26. https://iinventedlight.com/library/notes/docker-build-cache-backends/. License: CC-BY-4.0.
@misc{iil_note_m2ky6wj7,
author = {{iinventedlight}},
title = {{Docker Build cache backends: export and import an external cache}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/docker-build-cache-backends/},
note = {Permanent ID iil:note:m2ky6wj7. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- docker-build-cache-backends.schema.json (schema; CC-BY-4.0)
- docker-build-cache-backends.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-build-cache-backends.md.