By setting DOCKER_BUILD_CACHE_HOST_DIR
, the task-specific docker images built during the CI run can be cached. This allows, for example, ephemeral CI runners to reuse the docker images (or layers of it) from earlier runs, by persisting the image cache before the ephemeral CI runner is shut down. The cache keyed by CONTAINER_NAME
.
As --cache-to
doesn’t remove old cache files, the existing cache is removed after a successful docker build
and the newly cached image is moved to it’s location to avoid the cache from growing indefinitely with old, unused layers.
When --cache-from
doesn’t find the directory, the cached version is a cache-miss, or the cache can’t be imported for whatever other reason, it warns and docker build
continues by building the docker image.
This feature is opt-in. The documentation for the docker build cache of type=local
can be found on https://docs.docker.com/build/cache/backends/local/
This replaces #31377 - some of the discussion there might provide more context.