Compose "failed to solve" service build error in CI
When a service has a build: section, docker compose build hands the build to BuildKit. A "failed to solve" here is a normal BuildKit build failure for that service: the real cause is the named step in the service Dockerfile.
What this error means
A docker compose build or up --build fails with "failed to solve: process \"/bin/sh -c ...\" did not complete successfully" attached to a specific service.
failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1
ERROR: Service 'web' failed to buildCommon causes
A RUN step in the service Dockerfile failed
The service build hit the same BuildKit failure a standalone build would: a command exited non-zero.
A bad build context or build-arg for the service
A wrong context path or a missing build-arg the Dockerfile expects makes the service build fail.
How to fix it
Build the failing service directly to debug
- Build just that service so the BuildKit output is focused.
- Read the failing step and fix the Dockerfile or build-args.
- Re-run
docker compose build.
docker compose build web --progress=plainPass required build-args in the compose file
Provide any build arguments the service Dockerfile needs so the build has its inputs.
services:
web:
build:
context: ./web
args:
NODE_ENV: productionHow to prevent it
- Build services individually to isolate Dockerfile failures.
- Use
--progress=plainfor full build logs in CI. - Declare build-args the service Dockerfile expects.