diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index 3a4322371b..5e0cbac315 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -338,9 +338,18 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter, } for _, img := range images { - if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 { - img.RepoTags = append(img.RepoTags, ":") - img.RepoDigests = append(img.RepoDigests, "@") + if versions.LessThan(version, "1.43") { + if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 { + img.RepoTags = append(img.RepoTags, ":") + img.RepoDigests = append(img.RepoDigests, "@") + } + } else { + if img.RepoTags == nil { + img.RepoTags = []string{} + } + if img.RepoDigests == nil { + img.RepoDigests = []string{} + } } } diff --git a/daemon/images/image_prune.go b/daemon/images/image_prune.go index 6c461231eb..4aefd201e6 100644 --- a/daemon/images/image_prune.go +++ b/daemon/images/image_prune.go @@ -109,7 +109,7 @@ deleteImagesLoop: } } - // Only delete if it's untagged (i.e. repo:) + // Only delete if it has no references which is a valid NamedTagged. shouldDelete = !hasTag } diff --git a/docs/api/version-history.md b/docs/api/version-history.md index 6eeaee8e67..70553c27c1 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -20,6 +20,9 @@ keywords: "API, Docker, rcli, REST, documentation" * `POST /containers/create` now accepts `Annotations` as part of `HostConfig`. Can be used to attach arbitrary metadata to the container, which will also be passed to the runtime when the container is started. +* `GET /images/json` no longer includes hardcoded `:` and + `@` in `RepoTags` and`RepoDigests` for untagged images. + In such cases, empty arrays will be produced instead. ## v1.42 API changes diff --git a/testutil/environment/protect.go b/testutil/environment/protect.go index 8ef75a1848..58adc2fdd0 100644 --- a/testutil/environment/protect.go +++ b/testutil/environment/protect.go @@ -118,6 +118,9 @@ func getExistingImages(t testing.TB, testEnv *Execution) []string { func tagsFromImageSummary(image types.ImageSummary) []string { var result []string for _, tag := range image.RepoTags { + // Starting from API 1.43 no longer outputs the hardcoded + // strings. But since the tests might be ran against a remote + // daemon/pre 1.43 CLI we must still be able to handle it. if tag != ":" { result = append(result, tag) }