Skip to content
Latchkey

Docker "OCI runtime exec failed" - Fix docker exec Failures in CI

OCI runtime exec failed comes from docker exec, not container startup. runc could not run the command you asked it to exec inside the container - usually because that binary is not in the image, or the container is not running.

What this error means

A docker exec <container> <cmd> fails with OCI runtime exec failed: exec failed: unable to start container process: exec "<cmd>": executable file not found in $PATH. The container exists; the command you tried to exec does not.

docker exec output
OCI runtime exec failed: exec failed: unable to start container process:
exec: "bash": executable file not found in $PATH: unknown
# the image is Alpine (has sh/ash, not bash)

Diagnose it: read the container, not the compose file

A container that exits immediately in CI has almost always logged the reason and then been cleaned up. Capture the logs and the exit code before changing configuration.

Terminal
# why did it stop?
docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Image}}'
docker logs <container> 2>&1 | tail -50
docker inspect <container> --format '{{.State.ExitCode}} {{.State.OOMKilled}} {{.State.Error}}'

Common causes

The exec command is not in the image

Calling docker exec ... bash on an Alpine image (which has sh/ash, not bash), or any binary the image does not include, fails to find the executable.

The container is not running

docker exec only works on a running container. If it has exited (or never fully started), there is no process namespace to exec into.

Wrong PATH or a typo in the command

A binary installed in a non-standard location not on the container’s PATH, or a misspelled command, resolves to "not found".

How to fix it

Exec a shell the image actually has

Use sh on minimal images, or install the shell you need.

Terminal / Dockerfile
docker exec -it mycontainer sh          # works on Alpine
# or install bash in the image if you need it:
# RUN apk add --no-cache bash

Confirm the container is running first

Check status, and use the full path to the binary if PATH is the issue.

Terminal
docker ps --filter name=mycontainer    # must be Up, not Exited
docker exec mycontainer /usr/local/bin/mytool

How to prevent it

  • Use sh for exec on minimal images, or bake in the shell/tools you script against.
  • Verify the container is running before issuing docker exec.
  • Reference binaries by a path that exists on the container PATH.

Frequently asked questions

What causes Docker "OCI runtime exec failed"?
There are 3 common causes: the exec command is not in the image, the container is not running, and wrong path or a typo in the command. Calling docker exec ...
How do I fix Docker "OCI runtime exec failed"?
There are 2 fixes depending on which cause you have: exec a shell the image actually has and confirm the container is running first. Work through them in order, since the first is the most common.
What does Docker "OCI runtime exec failed" actually mean?
A docker exec <container> <cmd> fails with OCI runtime exec failed: exec failed: unable to start container process: exec "<cmd>": executable file not found in $PATH.
How do I stop Docker "OCI runtime exec failed" happening again?
Use sh for exec on minimal images, or bake in the shell/tools you script against. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card