Docker "failed to solve: process did not complete successfully: exit code: 2" in CI
A RUN step exited with code 2. BuildKit reports process "/bin/sh -c <cmd>" did not complete successfully: exit code: 2 - the command failed, commonly a make build error, a compiler error, or a tool that uses exit 2 for misuse.
What this error means
The build stops with failed to solve: process "/bin/sh -c <cmd>" did not complete successfully: exit code: 2. The failing command and its output are in the step log above the solve error.
#10 14.2 make: *** [Makefile:20: all] Error 2
#10 ERROR: process "/bin/sh -c make all" did not complete successfully: exit code: 2Common causes
make/compiler returned a build error (exit 2)
GNU make exits 2 on a failed target; many compilers and linters also use exit 2. The real error is the message above the BuildKit line.
Command-usage / argument error
Several CLIs exit 2 for "incorrect usage". A malformed flag in the RUN command produces exit 2 without doing the work.
Missing dependency surfaced as exit 2
A build that fails because a header, library, or tool is absent can bubble up as exit 2 from make/the compiler.
How to fix it
Read and fix the failing command
The exit 2 is from your command - fix the make target, compiler error, or flag in the step output.
RUN set -eux; \
make all # read the error above the BuildKit "exit code: 2" lineReproduce the step in the same image
Run the failing command interactively to see full output.
docker run --rm -it golang:1.22 sh -c 'make all'How to prevent it
- Add
set -euxto RUN steps so failures are explicit. - Install all build dependencies before the compile/make step.
- Validate command flags so usage errors do not exit 2.