Skip to content
Latchkey

Skaffold "docker build failed" in CI

Skaffold ran your Dockerfile through the docker builder and the build exited non-zero. Skaffold reports "docker build failed", but the actionable cause, a failing RUN, a missing file, or a bad base image, is in the streamed build log above.

What this error means

A build step ends with "building [my-app]: docker build failed" preceded by a Docker build error such as a failed RUN command or missing COPY source.

skaffold
building [my-app]: docker build failed:
  > [4/6] RUN npm ci:
  process "/bin/sh -c npm ci" did not complete successfully: exit code: 1

Common causes

A build step inside the Dockerfile failed

A RUN command (install, compile, test) exited non-zero, which fails the whole image build.

A missing COPY source or bad build context

A file referenced by COPY is not present in the build context, often because CI checks out a different set of files than a local build.

How to fix it

Read the failing build stage

  1. Scroll to the numbered stage [n/m] that failed in the log.
  2. Reproduce that RUN or COPY locally to see the real error.
  3. Fix the Dockerfile or add the missing context file, then re-run.

Verify the build context in CI

Ensure the files the Dockerfile copies are present after checkout and not excluded by .dockerignore.

Terminal
skaffold build -v debug --default-repo=us-docker.pkg.dev/my-project/my-repo

How to prevent it

  • Reproduce the exact Dockerfile build locally before pushing.
  • Keep .dockerignore in sync with what the Dockerfile expects.
  • Pin base image tags so a moved tag does not change the build.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →