{"record":{"id":"a2bf43728277f286","repo":"GoogleContainerTools/jib","slug":"docker-inspect-command-failed-with-error-gets","errorCode":null,"errorMessage":"'docker inspect' command failed with error: + getStderrOutput(inspectProcess)","messagePattern":"'docker inspect' command failed with error: \\+ getStderrOutput\\(inspectProcess\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/docker/CliDockerClient.java","lineNumber":286,"sourceCode":"\n    if (dockerProcess.waitFor() != 0) {\n      throw new IOException(\n          \"'docker save' command failed with error: \" + getStderrOutput(dockerProcess));\n    }\n  }\n\n  @Override\n  public DockerImageDetails inspect(ImageReference imageReference)\n      throws IOException, InterruptedException {\n    Process inspectProcess =\n        docker(\"inspect\", \"-f\", \"{{json .}}\", \"--type\", \"image\", imageReference.toString());\n\n    try (InputStreamReader stdout =\n        new InputStreamReader(inspectProcess.getInputStream(), StandardCharsets.UTF_8)) {\n      String output = CharStreams.toString(stdout);\n\n      if (inspectProcess.waitFor() != 0) {\n        throw new IOException(\n            \"'docker inspect' command failed with error: \" + getStderrOutput(inspectProcess));\n      }\n\n      return JsonTemplateMapper.readJson(output, DockerImageDetails.class);\n    }\n  }\n\n  /** Runs a {@code docker} command. */\n  private Process docker(String... subCommand) throws IOException {\n    return processBuilderFactory.apply(Arrays.asList(subCommand)).start();\n  }\n\n  private DockerInfoDetails fetchInfoDetails() throws IOException, InterruptedException {\n    Process infoProcess = docker(\"info\", \"-f\", \"{{json .}}\");\n\n    try (InputStreamReader stdout =\n        new InputStreamReader(infoProcess.getInputStream(), StandardCharsets.UTF_8)) {\n      String output = CharStreams.toString(stdout);","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/docker/CliDockerClient.java#L268-L304","documentation":"CliDockerClient.inspect() runs 'docker inspect <image>' and parses stdout as DockerImageDetails JSON. If the process exits nonzero, Jib throws IOException ''docker inspect' command failed with error: <stderr>'. Almost always this is because the image does not exist in the local docker daemon.","triggerScenarios":"Calling inspect(imageReference) for an image absent from the local docker cache, or when the docker daemon errors out; inspectProcess.waitFor() != 0 triggers the throw.","commonSituations":"Checking cache existence for an image that was never pulled or built, stale tag references after a rebuild, or docker CLI/daemon version mismatches.","solutions":["Confirm the image exists: 'docker images | grep <image>' or run 'docker inspect <image>' manually","Pull the image (docker pull) or build it locally before calling inspect()","Verify the exact tag/digest reference passed to inspect() is correct","Treat this exception in your code as 'image not cached' and fall back to building/pulling"],"exampleFix":"// before\nDockerImageDetails d = dockerClient.inspect(ref); // throws when image not local\n// after\ntry {\n  DockerImageDetails d = dockerClient.inspect(ref);\n} catch (IOException e) {\n  // image not in local docker cache — build/pull it first\n  buildOrPullImage(ref);\n  DockerImageDetails d = dockerClient.inspect(ref);\n}","handlingStrategy":"fallback","validationCode":"// Pre-check with docker CLI\nProcess p = new ProcessBuilder(\"docker\", \"inspect\", ref.toString()).start();\nboolean present = p.waitFor() == 0;","typeGuard":null,"tryCatchPattern":"DockerImageDetails details;\ntry {\n  details = dockerClient.inspect(ref);\n} catch (IOException e) {\n  // treat as 'not cached' and fall back to pull/build\n  buildOrPull(ref);\n  details = dockerClient.inspect(ref);\n}","preventionTips":["Use inspect() as an existence probe and expect IOException for missing images","Keep image references exact (name + tag/digest)","Run docker health checks before image operations"],"tags":["docker","docker-inspect","process","exit-code"],"backgroundTag":"docker-command-failed","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}