From 892a90bc1c707a426dee3c2a2ce93c325e188a1d Mon Sep 17 00:00:00 2001 From: Vincent Ducamps Date: Fri, 3 Jan 2025 10:38:43 +0000 Subject: [PATCH] backport of commit 6469b59a0a59451b80958c528393fbd1741e32fa --- .changelog/24547.txt | 3 +++ drivers/docker/driver_test.go | 2 ++ drivers/docker/utils.go | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 .changelog/24547.txt 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 != "" {