Skip to content
Latchkey

Docker "container ID file found but no such container" in CI

docker run --cidfile writes the new container ID to a file and refuses to overwrite it. If a prior job died before cleaning up, the leftover cidfile remains while the container it named is long gone, so the next docker run aborts.

What this error means

A docker run --cidfile=... fails with Container ID file found, make sure the other container isn't running or delete <path>, even though no container with that ID exists.

docker
docker: Error response from daemon: Container ID file found, make sure the other container isn't running or delete /tmp/app.cid.

Common causes

A stale cidfile from a crashed prior run

The previous job was cancelled or killed before it removed the cidfile.

A reused workspace path on a persistent runner

A self-hosted runner that reuses the same working directory keeps the old cidfile around.

How to fix it

Remove the stale cidfile before running

  1. Delete the cidfile (and any orphan container) at the start of the step.
Terminal
rm -f /tmp/app.cid
docker run --cidfile=/tmp/app.cid -d myorg/app:ci

Use a unique cidfile per run

  1. Put the cidfile in a per-job temp directory so old files never collide.
Terminal
CIDFILE="$(mktemp -d)/app.cid"
docker run --cidfile="$CIDFILE" -d myorg/app:ci

How to prevent it

  • Use a per-job unique cidfile path, or clean it up in a finally/post step.
  • Prefer ephemeral runners so stale state never carries over.

Frequently asked questions

What causes ""container ID file found""?
The previous job was cancelled or killed before it removed the cidfile.
How do I fix "container ID file found"?
Remove the stale cidfile before running

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card