GoogleContainerTools/jib · error · IOException

'docker inspect' command failed with error: + getStderrOutpu

Error message

'docker inspect' command failed with error: + getStderrOutput(inspectProcess)

What it means

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.

Source

Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/docker/CliDockerClient.java:286

    if (dockerProcess.waitFor() != 0) {
      throw new IOException(
          "'docker save' command failed with error: " + getStderrOutput(dockerProcess));
    }
  }

  @Override
  public DockerImageDetails inspect(ImageReference imageReference)
      throws IOException, InterruptedException {
    Process inspectProcess =
        docker("inspect", "-f", "{{json .}}", "--type", "image", imageReference.toString());

    try (InputStreamReader stdout =
        new InputStreamReader(inspectProcess.getInputStream(), StandardCharsets.UTF_8)) {
      String output = CharStreams.toString(stdout);

      if (inspectProcess.waitFor() != 0) {
        throw new IOException(
            "'docker inspect' command failed with error: " + getStderrOutput(inspectProcess));
      }

      return JsonTemplateMapper.readJson(output, DockerImageDetails.class);
    }
  }

  /** Runs a {@code docker} command. */
  private Process docker(String... subCommand) throws IOException {
    return processBuilderFactory.apply(Arrays.asList(subCommand)).start();
  }

  private DockerInfoDetails fetchInfoDetails() throws IOException, InterruptedException {
    Process infoProcess = docker("info", "-f", "{{json .}}");

    try (InputStreamReader stdout =
        new InputStreamReader(infoProcess.getInputStream(), StandardCharsets.UTF_8)) {
      String output = CharStreams.toString(stdout);

View on GitHub (pinned to fb949e2676)

Solutions

  1. Confirm the image exists: 'docker images | grep <image>' or run 'docker inspect <image>' manually
  2. Pull the image (docker pull) or build it locally before calling inspect()
  3. Verify the exact tag/digest reference passed to inspect() is correct
  4. Treat this exception in your code as 'image not cached' and fall back to building/pulling

Example fix

// before
DockerImageDetails d = dockerClient.inspect(ref); // throws when image not local
// after
try {
  DockerImageDetails d = dockerClient.inspect(ref);
} catch (IOException e) {
  // image not in local docker cache — build/pull it first
  buildOrPullImage(ref);
  DockerImageDetails d = dockerClient.inspect(ref);
}
Defensive patterns

Strategy: fallback

Validate before calling

// Pre-check with docker CLI
Process p = new ProcessBuilder("docker", "inspect", ref.toString()).start();
boolean present = p.waitFor() == 0;

Try / catch

DockerImageDetails details;
try {
  details = dockerClient.inspect(ref);
} catch (IOException e) {
  // treat as 'not cached' and fall back to pull/build
  buildOrPull(ref);
  details = dockerClient.inspect(ref);
}

Prevention

When it happens

Trigger: 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.

Common situations: Checking cache existence for an image that was never pulled or built, stale tag references after a rebuild, or docker CLI/daemon version mismatches.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/a2bf43728277f286. Report an issue: GitHub.