buildx "cache-from type=gha" not found / cache miss warning in CI
A --cache-from type=gha import that finds nothing is a cache miss, not a hard failure: the build still runs, just without reuse. A persistent miss usually means a mismatched scope, the cache expired, or this is the first run that populates it.
What this error means
Builds never hit the cache; logs show "importing cache manifest from gha" with no layers reused, or "failed to configure registry cache importer" warnings, and every step rebuilds.
#5 importing cache manifest from gha:...
#5 ERROR: failed to configure registry cache importer: ... not foundCommon causes
cache-to and cache-from use different scopes
If the export and import scopes do not match, the importer looks under a key nothing was written to and finds no cache.
The cache expired or never existed
GitHub evicts unused cache after a retention window, and the very first build has nothing to import.
How to fix it
Match scope on cache-to and cache-from
- Use the same
scopevalue on bothcache-toandcache-from. - Ensure at least one prior build wrote the cache with
cache-to. - Treat the first run as a cold build that populates the cache.
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}Order layers for better reuse
Copy dependency manifests and install before copying source so the heavy install layer caches across runs.
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .How to prevent it
- Keep cache-to and cache-from scopes identical.
- Order Dockerfile layers from least to most frequently changing.
- Expect cold builds on the first run and after cache eviction.