Skip to main content

Docker layer caching

When a layer changes in your Docker image, that layer must be rebuilt. Additionaly, all layers that come after must also be rebuilt. Docker layer caching allows these layers to be cached and reused between your pipelines, which can dramatically reduce build times.

Write your Dockerfiles to use the cache efficiently.

Docker layer caching with Harness Cloud

Harness Cloud can manage the Docker layer cache backend for you, without relying on your Docker registry. This ensures that layers are always pulled from the fastest available source.

Enable Docker layer caching by selecting Enable Docker layer caching in your Docker build and push step.


Currently, Docker layer caching with Harness Cloud is behind a feature flag. Contact Harness Support to enable the feature.

Docker layer caching with other build infrastructures

Other build infrastructures can leverage remote Docker caching using your existing Docker registry.


Support for other storage backends with self-hosted runners is in development.

Each Docker layer is uploaded as an image to a Docker repo you identify. If the same layer is used in subsequent builds, Harness downloads the layer from the Docker repo. You can also specify the same Docker repo for multiple Docker build steps, enabling them to share the same remote cache.

You can enable the Remote Cache Image option in the following steps: