GoogleContainerTools/skaffold · error
docker build failure: %w
Error message
docker build failure: %w
What it means
While streaming the build's JSON messages, a *jsonstream.Error was received — the daemon reported the build itself failed (e.g. a RUN command exited non-zero). Skaffold detects the error type via errors.As and rewraps it as `docker build failure` to distinguish a real build failure from a transport problem.
Source
Thrown at pkg/skaffold/docker/image.go:402
var imageID string
auxCallback := func(msg jsonstream.Message) {
if msg.Aux == nil {
return
}
var result BuildResult
if err := json.Unmarshal(*msg.Aux, &result); err != nil {
log.Entry(ctx).Debug("Unable to parse build output:", err)
return
}
imageID = result.ID
}
if err := streamDockerMessages(out, resp.Body, auxCallback); err != nil {
var jm *jsonstream.Error
if errors.As(err, &jm) {
return "", fmt.Errorf("docker build failure: %w", err)
}
return "", fmt.Errorf("unable to stream build output: %w", err)
}
if imageID == "" {
// Maybe this version of Docker doesn't return the digest of the image
// that has been built.
imageID, err = l.ImageID(ctx, opts.Tag)
if err != nil {
return "", fmt.Errorf("getting digest: %w", err)
}
}
return imageID, nil
}
// streamDockerMessages streams formatted json output from the docker daemon
func streamDockerMessages(dst io.Writer, src io.Reader, auxCallback func(jsonstream.Message)) error {View on GitHub (pinned to a1189de023)
Solutions
- Read the wrapped jsonstream error output to find the failing Dockerfile step
- Fix the failing instruction in the Dockerfile
- Rebuild with --no-cache if a cached layer masks the issue
- Check base image names/tags and registry authentication
Example fix
// before RUN npm test # failing step // after RUN npm run build # corrected/removed failing step
Defensive patterns
Strategy: try-catch
Try / catch
var jm *jsonstream.Error
if err := ...; errors.As(err, &jm) {
// inspect jm for the failing Dockerfile step and fix the Dockerfile
return fmt.Errorf("build step failed: %v", jm)
} Prevention
- Run `docker build .` directly first to iterate on Dockerfile errors
- Test RUN steps (tests, lint) outside the Dockerfile during development
- Validate base image tags and registry access before CI builds
- Watch daemon disk space; prune old images periodically
When it happens
Trigger: streamDockerMessages returns a *jsonstream.Error, i.e. the Docker daemon sent an error message during the build — a failing RUN/COPY step, exit code != 0 in a Dockerfile instruction, or a step the daemon could not execute.
Common situations: Dockerfile bug (typo in package name, failing test in RUN); missing base image or registry auth; COPY of a file excluded by .dockerignore; disk full on the daemon host.
Related errors
- normalizing dockerfile path: %w
- reading dockerfile: %w
- removing unused default args: %w
- normalizing dockerfilePath path: %w
- normalizing dockerfile path: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/c31053a2caa0c27a.
Report an issue: GitHub.