Docker Compose "service failed to build" in CI
Compose reports that a service could not build, but the real error is in the wrapped Dockerfile build above it: a failed COPY, RUN, or a missing context, surfaced through compose.
What this error means
A docker compose build or up --build fails with failed to build: <service> or Service <name> failed to build. The underlying build error appears just above.
docker
[+] Building 12.3s (8/14)
failed to solve: failed to compute cache key: "/package.json": not found
Service 'web' failed to build: COPY failedCommon causes
Underlying Dockerfile build failed
A COPY/RUN/parse error in the service Dockerfile is the true failure; compose only wraps it.
Wrong build context or dockerfile path
The service build.context or build.dockerfile in compose points at the wrong location.
How to fix it
Read the wrapped build error
- Look above the compose failure line for the real Dockerfile error and fix that.
- Build the single service with plain progress to see full output.
Terminal
docker compose build --progress=plain webFix the build config
- Confirm build.context and build.dockerfile resolve to real paths.
docker-compose.yml
services:
web:
build:
context: ./web
dockerfile: DockerfileHow to prevent it
- Treat compose build failures as Dockerfile failures: read the wrapped error and keep build.context/dockerfile paths correct. This is deterministic, not transient.
Related guides
Docker "failed to compute cache key: not found" in CIFix the Docker "failed to compute cache key: ... not found" build error in CI, caused by a COPY or ADD source…
Docker "COPY failed: file not found in build context" in CIFix the Docker "COPY failed: file not found in build context" error in CI, caused by copying a path absent fr…
Docker "docker-compose: command not found" (v1 vs v2) in CIFix the "docker-compose: command not found" CI error from the v1 to v2 move, where Compose is now the `docker…