20 Nov, 2026Mahesh Kale
Concurrent Docker Builds on Monk CI Explained
Understand Monk CI Docker cache writer and reader roles, concurrent build behavior, and how to check which cache updates survive a job.
Three pull requests build the same service at once. They share much of their starting code, but each may create different Docker layers.
Reusing common work sounds simple. Letting every build publish changes to the same mutable state is where ownership starts to matter.
For Monk CI, the useful distinction is between reusing cache and publishing cache updates.
A cache reader can still build an image
Monk CI's published migration guide describes two roles exposed by its setup action:
- canonical_writer: layers are published back to the shared cache.
- disposable_clone: layers added by that build are discarded at job end.
The v1 action definition still exposes these controller-assigned roles for the current lease. These labels describe cache publication, not permanent identities for particular runners.
A disposable clone can perform build work. Discarding its cache additions is separate from producing an image or pushing that image to a registry

Role semantics from the published guide. This does not specify the storage or locking implementation.
Why split those responsibilities?
BuildKit state includes metadata and snapshots as well as reusable results. Multiple independent builders directly mutating the same state need a coordination design.
The role model gives a developer a useful question to ask: did this build merely benefit from earlier work, or could it also make new cache work available later?
That explains a result that can otherwise look odd. A concurrent job may finish correctly, yet a later build may not reuse the layers that job alone created. Under the documented disposable-clone role, retaining those additions is not its responsibility.
Explicit cache publication ownership makes concurrent build behavior easier to reason about. The role names alone do not prove how races, fencing or storage failure are handled.
Record the role before guessing
Add an ID to the existing setup step, then record its outputs:
- uses: MonkCi-Inc/setup-docker-builder@v1
id: builder
- name: Show cache context
env:
CACHE_FOUND: ${{ steps.builder.outputs.cache-hit }}
CACHE_ROLE: ${{ steps.builder.outputs.cache-role }}
run: |
printf 'cache_found=%s cache_role=%s\n' \
"$CACHE_FOUND" "$CACHE_ROLE"
The current action metadata says the role can be empty when the cache path is disabled or the runner agent predates that output. An empty value is not enough evidence to label a job a reader or writer.
Also check build-step output. Finding an existing cache does not mean every requested layer matches.
Reuse needs a trust boundary too
The current product guide describes repository-scoped Docker cache. That is useful scope information, but it does not fully describe branch permissions or access from untrusted fork builds.
Before relying on reuse across a trust boundary, check the applicable permissions and product behavior. Do not assume a cache-role label is a complete security policy.
A small concurrency check is useful
Start two overlapping builds from the same base revision and record their roles. Change app code in one and a dependency input in the other.
Check each image's correctness first. Then inspect what a later build can reuse, and keep cancellations or failures with the test record.
Keep the repository, commit, runner size and build settings with each log so later comparisons have useful context.
Takeaway: separate the right to reuse work from the right to publish cache updates. That helps explain concurrent build behavior without treating every missing cache layer as a failed build.