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

note

Currently, Docker layer caching with Harness Cloud is behind the feature flags CI_ENABLE_DLC and CI_HOSTED_CONTAINERLESS_OOTB_STEP_ENABLED. Contact Harness Support to enable the feature.

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.

To enable Docker layer caching for Harness Cloud, select Enable Docker layer caching in your Build and Push to Docker step.

Docker layer caching with other build infrastructures

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

note

Harness is developing support for other storage backends with self-managed runners.

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: