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: 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
- Delete the cidfile (and any orphan container) at the start of the step.
rm -f /tmp/app.cid
docker run --cidfile=/tmp/app.cid -d myorg/app:ciUse a unique cidfile per run
- Put the cidfile in a per-job temp directory so old files never collide.
CIDFILE="$(mktemp -d)/app.cid"
docker run --cidfile="$CIDFILE" -d myorg/app:ciHow 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.