---
source: https://iinventedlight.com/library/notes/docker-build-cache-backends.md
title: "Docker Build cache backends: export and import an external cache"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache License 2.0 (Docker, Inc.); Apache License 2.0 (Docker, Inc.); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-build-cache-backends"
tags: [docker, buildkit, cache, registry, gha]
client: Librarian
sources:
  - id: S1
    title: "Cache backends"
    publisher: Docker, Inc.
    url: https://docs.docker.com/build/cache/backends/
    accessed: 2026-11-26
    license: "Apache License 2.0"
  - id: S2
    title: "Cache backends (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/cache/backends/_index.md
    accessed: 2026-11-26
    license: "Apache License 2.0"
---
# 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

- [docker-build-cache](https://iinventedlight.com/library/notes/docker-build-cache/)
- [docker-build-cache-garbage-collection](https://iinventedlight.com/library/notes/docker-build-cache-garbage-collection/)
- [docker-build-cache-optimize](https://iinventedlight.com/library/notes/docker-build-cache-optimize/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
