Merge pull request #35790 from thaJeztah/image-shortid
Remove support for referencing images by 'repository:shortid'
diff --git a/daemon/image.go b/daemon/image.go
index 6e90429..486f2a2 100644
--- a/daemon/image.go
+++ b/daemon/image.go
@@ -6,7 +6,6 @@
"github.com/docker/distribution/reference"
"github.com/docker/docker/image"
- "github.com/docker/docker/pkg/stringid"
)
// errImageDoesNotExist is error returned when no image can be found for a reference.
@@ -59,21 +58,6 @@
return id, imageOS, nil
}
- // deprecated: repo:shortid https://github.com/docker/docker/pull/799
- if tagged, ok := namedRef.(reference.Tagged); ok {
- if tag := tagged.Tag(); stringid.IsShortID(stringid.TruncateID(tag)) {
- for platform := range daemon.stores {
- if id, err := daemon.stores[platform].imageStore.Search(tag); err == nil {
- for _, storeRef := range daemon.referenceStore.References(id.Digest()) {
- if storeRef.Name() == namedRef.Name() {
- return id, platform, nil
- }
- }
- }
- }
- }
- }
-
// Search based on ID
for os := range daemon.stores {
if id, err := daemon.stores[os].imageStore.Search(refOrID); err == nil {
diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go
index f5fe0da..8e12314 100644
--- a/integration-cli/docker_cli_create_test.go
+++ b/integration-cli/docker_cli_create_test.go
@@ -268,7 +268,6 @@
dockerCmd(c, "create", imageID)
dockerCmd(c, "create", truncatedImageID)
- dockerCmd(c, "create", fmt.Sprintf("%s:%s", imageName, truncatedImageID))
// Ensure this fails
out, exit, _ := dockerCmdWithError("create", fmt.Sprintf("%s:%s", imageName, imageID))
@@ -280,7 +279,10 @@
c.Fatalf(`Expected %q in output; got: %s`, expected, out)
}
- out, exit, _ = dockerCmdWithError("create", fmt.Sprintf("%s:%s", "wrongimage", truncatedImageID))
+ if i := strings.IndexRune(imageID, ':'); i >= 0 {
+ imageID = imageID[i+1:]
+ }
+ out, exit, _ = dockerCmdWithError("create", fmt.Sprintf("%s:%s", "wrongimage", imageID))
if exit == 0 {
c.Fatalf("expected non-zero exit code; received %d", exit)
}
diff --git a/integration-cli/docker_cli_tag_test.go b/integration-cli/docker_cli_tag_test.go
index ee94a9b..278e348 100644
--- a/integration-cli/docker_cli_tag_test.go
+++ b/integration-cli/docker_cli_tag_test.go
@@ -1,13 +1,10 @@
package main
import (
- "fmt"
"strings"
"github.com/docker/docker/integration-cli/checker"
- "github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/testutil"
- "github.com/docker/docker/pkg/stringid"
"github.com/go-check/check"
)
@@ -140,29 +137,3 @@
c.Fatal("tagging with image named \"sha256\" should have failed")
}
}
-
-// ensure tags cannot create ambiguity with image ids
-func (s *DockerSuite) TestTagTruncationAmbiguity(c *check.C) {
- buildImageSuccessfully(c, "notbusybox:latest", build.WithDockerfile(`FROM busybox
- MAINTAINER dockerio`))
- imageID := getIDByName(c, "notbusybox:latest")
- truncatedImageID := stringid.TruncateID(imageID)
- truncatedTag := fmt.Sprintf("notbusybox:%s", truncatedImageID)
-
- id := inspectField(c, truncatedTag, "Id")
-
- // Ensure inspect by image id returns image for image id
- c.Assert(id, checker.Equals, imageID)
- c.Logf("Built image: %s", imageID)
-
- // test setting tag fails
- _, _, err := dockerCmdWithError("tag", "busybox:latest", truncatedTag)
- if err != nil {
- c.Fatalf("Error tagging with an image id: %s", err)
- }
-
- id = inspectField(c, truncatedTag, "Id")
-
- // Ensure id is imageID and not busybox:latest
- c.Assert(id, checker.Not(checker.Equals), imageID)
-}