30 Nov, 2026Akshit Mandial
Migrate your Docker builds to Monk CI
Monk CI runners replace the GitHub Actions cache with a persistent BuildKit state volume. Build layers stay on the local disk between jobs, so builds skip the layer export/import round trip on every run.
Monk CI keeps a Docker layer cache for each repository on local NVMe storage, so your GitHub Actions Docker builds start warm. Each build reuses the layers from earlier jobs.
To use the cache, you need two Monk CI actions:
- `MonkCi-Inc/setup-docker-builder@v1` sets up a BuildKit builder that uses the persistent cache.
- `MonkCi-Inc/build-push-action@v1` builds and pushes your image with that builder.
If you change only the builder setup, or build with `docker/build-push-action` or a plain `docker build`, the build does not use the cache.
Migrate the workflow
Apply these changes to your build job:
jobs:
build:
- runs-on: ubuntu-latest
+ runs-on: monkci-ubuntu-24.04-4
steps:
- uses: actions/checkout@v4
- - uses: docker/setup-buildx-action@v3
+ - uses: MonkCi-Inc/setup-docker-builder@v1
- - uses: docker/build-push-action@v6
+ - uses: MonkCi-Inc/build-push-action@v1
with:
context: .
tags: myorg/myapp:${{ github.sha }}
push: false
- cache-from: type=gha
- cache-to: type=gha,mode=max- Change the runner label to a Monk CI runner label.
- Replace `docker/setup-buildx-action` with `MonkCi-Inc/setup-docker-builder`.
- Replace `docker/build-push-action` with `MonkCi-Inc/build-push-action`. It accepts the same main inputs, such as `context`, `file`, `tags`, `push`, `build-args` and `platforms`.
- Remove `cache-from` and `cache-to`. The persistent BuildKit state volume holds the cache, so you do not need the `type=gha` directives.
Configure the builder
setup-docker-builder accepts the following optional inputs:
| Input | Description |
|---|---|
| nofallback | When true, the job fails instead of falling back to a local, cacheless builder. |
| buildkit-version | Pins the BuildKit release instead of tracking the latest. |
Read builder outputs
Assign an id to the setup step to reference its outputs:
| Output | Description |
|---|---|
| cache-hit | true when a warm cache was found and passed pre-flight. |
| cache-role | 'canonical_writer' if the layers are published back to the shared cache, or 'disposable_clone' if they are discarded at job end. |
| builder-name | The buildx builder instance name. |
| volume-name, mount-path | The cache volume identity and mount point, for debugging. |
steps:
- uses: actions/checkout@v4
- uses: MonkCi-Inc/setup-docker-builder@v1
id: builder
with:
nofallback: true
buildkit-version: v0.28.0
- uses: MonkCi-Inc/build-push-action@v1
with:
context: .
tags: myorg/myapp:${{ github.sha }}
push: false
- run: echo "cache-hit=${{ steps.builder.outputs.cache-hit }} role=${{ steps.builder.outputs.cache-role }}"For a full workflow with a registry login and push, read the Docker builds guide.