diff --git a/.changelog/24547.txt b/.changelog/24547.txt new file mode 100644 index 00000000000..3e8f8f90131 --- /dev/null +++ b/.changelog/24547.txt @@ -0,0 +1,3 @@ +```release-note:bug +docker: Fix a bug where images with port number and no tags weren't parsed correctly +``` diff --git a/drivers/docker/driver_test.go b/drivers/docker/driver_test.go index 99e6e6ef8de..77437f819a5 100644 --- a/drivers/docker/driver_test.go +++ b/drivers/docker/driver_test.go @@ -2860,6 +2860,8 @@ func TestParseDockerImage(t *testing.T) { Repo string Tag string }{ + {"host:5000/library/hello-world", "host:5000/library/hello-world", "latest"}, + {"host:5000/library/hello-world:1.0", "host:5000/library/hello-world", "1.0"}, {"library/hello-world:1.0", "library/hello-world", "1.0"}, {"library/hello-world", "library/hello-world", "latest"}, {"library/hello-world:latest", "library/hello-world", "latest"}, diff --git a/drivers/docker/utils.go b/drivers/docker/utils.go index 77a120c5a2f..c329a079f80 100644 --- a/drivers/docker/utils.go +++ b/drivers/docker/utils.go @@ -31,6 +31,9 @@ func parseDockerImage(image string) (repo, tag string) { } else if t := repoTag[idx+1:]; !strings.Contains(t, "/") { repo = repoTag[:idx] tag = t + } else if t := repoTag[idx+1:]; strings.Contains(t, "/") { + repo = image + tag = "latest" } if tag != "" {