Skip to content
Latchkey

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.

compose
failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1
ERROR: Service 'web' failed to build

Common 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

  1. Build just that service so the BuildKit output is focused.
  2. Read the failing step and fix the Dockerfile or build-args.
  3. Re-run docker compose build.
Terminal
docker compose build web --progress=plain

Pass required build-args in the compose file

Provide any build arguments the service Dockerfile needs so the build has its inputs.

docker-compose.yml
services:
  web:
    build:
      context: ./web
      args:
        NODE_ENV: production

How to prevent it

  • Build services individually to isolate Dockerfile failures.
  • Use --progress=plain for full build logs in CI.
  • Declare build-args the service Dockerfile expects.

Frequently asked questions

What causes ""failed to solve" (compose build)"?
The service build hit the same BuildKit failure a standalone build would: a command exited non-zero.
How do I fix "failed to solve" (compose build)?
Build the failing service directly to debug

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card