Skip to content

Guides

How to share a Docker cache between jobs

Each matrix leg rebuilds the same layers.

5 min read

Each matrix leg rebuilds the same layers.

Why it happens

Every job gets its own BuildKit instance with an empty cache unless you attach them to a shared builder.

How to fix it

  1. Attach all jobs to one persistent remote builder
  2. If using registry cache, have one job populate it and the rest read from it
  3. Order the Dockerfile so shared layers come first

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.