{"record":{"id":"c31053a2caa0c27a","repo":"GoogleContainerTools/skaffold","slug":"docker-build-failure-w","errorCode":null,"errorMessage":"docker build failure: %w","messagePattern":"docker build failure: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/image.go","lineNumber":402,"sourceCode":"\n\tvar imageID string\n\tauxCallback := func(msg jsonstream.Message) {\n\t\tif msg.Aux == nil {\n\t\t\treturn\n\t\t}\n\n\t\tvar result BuildResult\n\t\tif err := json.Unmarshal(*msg.Aux, &result); err != nil {\n\t\t\tlog.Entry(ctx).Debug(\"Unable to parse build output:\", err)\n\t\t\treturn\n\t\t}\n\t\timageID = result.ID\n\t}\n\n\tif err := streamDockerMessages(out, resp.Body, auxCallback); err != nil {\n\t\tvar jm *jsonstream.Error\n\t\tif errors.As(err, &jm) {\n\t\t\treturn \"\", fmt.Errorf(\"docker build failure: %w\", err)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"unable to stream build output: %w\", err)\n\t}\n\n\tif imageID == \"\" {\n\t\t// Maybe this version of Docker doesn't return the digest of the image\n\t\t// that has been built.\n\t\timageID, err = l.ImageID(ctx, opts.Tag)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"getting digest: %w\", err)\n\t\t}\n\t}\n\n\treturn imageID, nil\n}\n\n// streamDockerMessages streams formatted json output from the docker daemon\nfunc streamDockerMessages(dst io.Writer, src io.Reader, auxCallback func(jsonstream.Message)) error {","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/image.go#L384-L420","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nRUN npm test   # failing step\n// after\nRUN npm run build   # corrected/removed failing step","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"var jm *jsonstream.Error\nif err := ...; errors.As(err, &jm) {\n\t// inspect jm for the failing Dockerfile step and fix the Dockerfile\n\treturn fmt.Errorf(\"build step failed: %v\", jm)\n}","preventionTips":["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"],"tags":["docker","build-failure","dockerfile"],"backgroundTag":"dockerfile-step-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}