Docker "executor failed running [/bin/sh -c ...]" in CI
A RUN step failed. The executor failed running [/bin/sh -c <cmd>] line is BuildKit reporting that the shell command inside that RUN exited non-zero - the real cause is in the command output just above it.
What this error means
The build stops with executor failed running [/bin/sh -c <your command>]: exit code: N. The wrapper names the command; the actual error (a failed install, a missing binary, a test failure) is printed in the step output above.
#9 [build 4/6] RUN make build
#9 12.4 make: *** [Makefile:12: build] Error 2
#9 ERROR: executor failed running [/bin/sh -c make build]: exit code: 2Common causes
The command genuinely failed
A compile error, a failing test, or a tool returning non-zero makes the RUN step exit non-zero. The executor line is the symptom, not the cause.
A missing tool or dependency in the image
The command relies on a binary or package not installed in the base image, so it errors out (often not found or a missing-library message above the executor line).
Shell semantics hide the real failure
Chained commands (a && b) or a piped command without set -o pipefail can surface a confusing exit code; the failing sub-command is in the output.
How to fix it
Read the command output above the executor line
Scroll up to the actual error from the command and fix that - install the missing tool, fix the failing build, etc.
# make the failure explicit and stop on pipe errors
RUN set -eux -o pipefail; \
make buildReproduce the step locally
Run the same image and command interactively to see the full error.
docker run --rm -it node:20-slim sh -c 'make build'How to prevent it
- Use
set -eux -o pipefailin non-trivial RUN steps so failures surface clearly. - Install every tool a RUN command needs earlier in the Dockerfile.
- Reproduce failing steps with
docker runbefore debugging the build.