{"record":{"id":"f24f147b920d6e72","repo":"docker/cli","slug":"server-did-not-provide-an-image-id-cannot-write","errorCode":null,"errorMessage":"server did not provide an image ID. Cannot write %s","messagePattern":"server did not provide an image ID\\. Cannot write (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/image/build.go","lineNumber":390,"sourceCode":"\t\t\t}\n\t\t\tif options.quiet {\n\t\t\t\t_, _ = fmt.Fprintf(dockerCli.Err(), \"%s%s\", progBuff, buildBuff)\n\t\t\t}\n\t\t\treturn cli.StatusError{Status: jerr.Message, StatusCode: jerr.Code}\n\t\t}\n\t\treturn err\n\t}\n\n\t// Everything worked so if -q was provided the output from the daemon\n\t// should be just the image ID and we'll print that to stdout.\n\tif options.quiet {\n\t\timageID = fmt.Sprintf(\"%s\", buildBuff)\n\t\t_, _ = fmt.Fprint(dockerCli.Out(), imageID)\n\t}\n\n\tif options.imageIDFile != \"\" {\n\t\tif imageID == \"\" {\n\t\t\treturn fmt.Errorf(\"server did not provide an image ID. Cannot write %s\", options.imageIDFile)\n\t\t}\n\t\tif err := os.WriteFile(options.imageIDFile, []byte(imageID), 0o666); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// validateTag checks if the given image name can be resolved.\nfunc validateTag(rawRepo string) (string, error) {\n\t_, err := reference.ParseNormalizedNamed(rawRepo)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn rawRepo, nil\n}","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/image/build.go#L372-L408","documentation":"Returned by runBuild (build.go:390) when --iidfile was requested but after a successful build the resolved imageID is empty. The CLI resolves the ID either from the daemon's aux JSON messages or, in quiet mode, from the build output buffer. An empty ID means the server stream completed without ever providing an image identifier, so there is nothing to write to the iidfile.","triggerScenarios":"The daemon/build backend finished the build stream without emitting an 'aux' message containing Result.ID, and quiet mode produced no ID either. Seen with remote builders (buildkit/buildx backends) that stream differently, with daemons that emit a non-standard aux shape the CLI cannot parse (the parse error is only logged to stderr at build.go:359), or when the build actually failed server-side but closed the stream cleanly.","commonSituations":"Mixing an older CLI with a newer daemon (or vice versa) where the aux message schema changed; using DOCKER_BUILDKIT=1 with a buildkit version that emits IDs differently; a proxy/middlebox altering the stream; the build produced no final image (e.g., multi-stage with no default target).","solutions":["Re-run without --iidfile and inspect the full output to see if an ID is emitted at all.","Ensure CLI and daemon versions are compatible: 'docker version' and align client/server.","If using buildkit/buildx, prefer 'docker buildx build --iidfile <path>' which handles ID extraction for that backend.","Check stderr for the 'Failed to parse aux message' line (build.go:359) which indicates an aux-schema mismatch."],"exampleFix":"# before (classic builder + iidfile, daemon emits no ID)\nDOCKER_BUILDKIT=1 docker build --iidfile id.txt .\n# after (use buildx for buildkit builds)\ndocker buildx build --iidfile id.txt --load .","handlingStrategy":"validation","validationCode":"// After a build, parse the iidfile to confirm an ID was written; if using buildkit,\n// prefer buildx which reliably emits an ID.\nfunc buildAndReadID(target string) (string, error) {\n\tcmd := exec.Command(\"docker\", \"buildx\", \"build\", \"--iidfile\", target, \"--load\", \".\")\n\tif err := cmd.Run(); err != nil { return \"\", err }\n\treturn os.ReadFile(target)\n}","typeGuard":null,"tryCatchPattern":"if err := buildCmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"server did not provide an image ID\") {\n\t\t// daemon/backend mismatch; retry without --iidfile or switch to buildx\n\t}\n}","preventionTips":["Keep CLI and daemon versions aligned.","Use 'docker buildx build --iidfile' for buildkit-based builds.","Watch stderr for 'Failed to parse aux message' which signals an aux-schema mismatch."],"tags":["build","iidfile","image-id","daemon-compat"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}