Half of our pipelines were failing on the same Docker error, and each failure burned 25 minutes before the job timed out. The fix was not a retry loop, because the error was a symptom of something else on the build machine deleting files while a pull was running. Here is how I found that something, and what I left behind so the next failure of this kind stops in minutes instead of 25.

The Symptom

The integration-test job starts a local Supabase stack with npx supabase start, which pulls about six container images. On every other pipeline, one pull died with this:

failed commit on ref ... no such file or directory

The CLI did not give up. It retried the same ingest path, hit the same error, and looped until the job’s 25-minute timeout. Roughly every other pipeline failed, which is the worst kind of failure to debug.

Why I Did Not Add a Retry

A retry loop was the five-minute answer. I skipped it because of what the error says: a file went missing in the middle of a pull. A flaky network usually looks different. This looks like what happens when something else is deleting layers while the pull is writing them. A retry would just walk into the same race again, more slowly.

I wrote down the candidates before looking at anything: network trouble, a bug in the Supabase CLI, disk pressure on the runner, or something deleting data under Docker. Each of the first three would have ended in a band-aid. Only the fourth explained why the failure was sporadic and why it surfaced as a missing file.

Looking at the Runner

The CI runner is a plain Linux machine. I checked what was scheduled on it:

ssh ci-runner.example.com "sudo systemctl list-timers --all | grep docker"
ssh ci-runner.example.com "sudo crontab -l"
ssh ci-runner.example.com "sudo crontab -u gitlab-runner -l"

Two cleanup jobs came back:

  1. A script in root’s crontab, every six hours, that removed old commit-tagged images of our own, dangling images, and the builder cache.
  2. A script in the CI user’s crontab, daily at 04:00, that ran docker image prune -af --filter until=72h.

The second one matters. According to Docker’s documentation, -a removes all images that are not used by at least one container, and until filters on when an image was created, not when it was pulled. A freshly pulled image of an older build has no container yet and is already old, so it qualifies on both counts.

Our CI config had a comment warning people not to add pipeline-level prunes for this reason. The host-level crons got past that rule because they had been set up months earlier, on the machine, outside the repository.

My explanation is this: a prune starts, a pull begins at the same moment, a layer disappears under the pull, and the pull’s half-written state is left pointing at a file that no longer exists. Every retry then fails on the same dead state. I did not reproduce the race on demand, so I treat this as the best explanation that fits the symptom and the schedule, not as a proven cause.

What I Changed

Deleting one cron would have fixed today’s failure and left the machine one hand edit away from doing it again. I made three changes.

The cleanup script went into the repo. The version the runner actually executes is now version-controlled and reviewable. It dropped the -a flag, so images pulled from public registries are no longer swept up. It trims only our own old commit-tagged images and keeps the newest three per repository, which preserves the original goal of reclaiming disk.

The other cron was disabled with a trail. I renamed the script with a .disabled suffix and a ticket reference and removed its crontab line. Anyone who finds the file later can read why.

The job now fails fast. Before starting Supabase, the job pulls each required image with a short timeout:

PREFLIGHT_TIMEOUT=60   # seconds, per image
required_images=(
  "public.ecr.aws/supabase/postgres:17.6.1.106"
  "public.ecr.aws/supabase/gotrue:v2.184.0"
  # ...the other four
)

for image in "${required_images[@]}"; do
  if ! timeout "$PREFLIGHT_TIMEOUT" docker pull "$image" >/dev/null; then
    echo "Preflight failed for $image: runner needs ops attention"
    echo "Likely cause: containerd ingest race. See the CI troubleshooting table."
    exit 1
  fi
done

If I am wrong about the cause, or something else deletes layers before the preflight reaches them, the job fails within a minute of the first image that hangs and names the likely cause. Docker’s own error text stays in the job log, because I only silence stdout. Before, it hung for 25 minutes with an error that said nothing.

Limits

  • The preflight does not prevent the race. It only turns a 25-minute hang into a short failure. The timeout is per image, so with six images the worst case is a few minutes, not one. If the cause is something other than prune jobs, the preflight still fails and the hint in the message points at the wrong thing.
  • It only covers deletions that happen before it runs. If something deletes layers after the preflight succeeds, Supabase pulls them again outside the timeout, and that pull can hang the way the original did.
  • It adds a pull to every run. On a warm runner the images are already there and this is quick. On a cold runner it adds time before the real work starts.
  • The versions in the snippet are pinned to what we used then. Pin your own image tags before copying it.
  • This is one runner. The fix assumes a single machine with a human who can SSH in. I would expect a fleet of ephemeral runners to avoid this entirely, because nothing would be pruning shared state.

What I Would Take From It

Read the error for what it implies about the environment. no such file or directory in the middle of a download is not a network message. And when the machine has jobs that were set up by hand, look at its crontab before you look at the code.