Skip to content

ImageDigest cannot tell a missing image from one with no registry digest #35

Description

@lefoulkrod
func (e *DockerEngine) ImageDigest(image string) string {
	cmd := buildCmd("docker", "inspect", "--format", "{{index .RepoDigests 0}}", image)
	out, err := cmd.Output()
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(out))
}

RepoDigests is populated by pulling from a registry. An image built locally, loaded from an archive, or tagged from another local image has none, so the index fails and this returns "" — the same answer it gives for an image that is not on the machine at all.

Observed as Doctor reporting Omnideck download: warn — Could not confirm the downloaded app image, which reads like a problem with the download rather than "this image did not come from a registry".

Suggestion

Now that ImageExists is on the engine interface, callers that want presence should ask that, and ImageDigest should be understood as "the registry digest, if it has one". Worth auditing the callers and, where the distinction matters, reporting unknown rather than missing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions