From e2708fb59b33d5eaf4a42232c71e2c1ff4367f82 Mon Sep 17 00:00:00 2001 From: apostasie Date: Mon, 2 Dec 2024 15:47:47 -0800 Subject: [PATCH] Fix hosts.toml resolution for docker domain Signed-off-by: apostasie --- pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go b/pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go index 5262dd729d0..8577b8e2bc6 100644 --- a/pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go +++ b/pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go @@ -82,6 +82,13 @@ func NewHostOptions(ctx context.Context, refHostname string, optFuncs ...Opt) (* ho.HostDir = func(hostURL string) (string, error) { regURL, err := Parse(hostURL) + // Docker inconsistencies handling: `index.docker.io` actually expects `docker.io` for hosts.toml on the filesystem + // See https://github.com/containerd/nerdctl/issues/3697 + // FIXME: we need to reevaluate this comparing with what docker does. What should happen for FQ images with alternate docker domains? (eg: registry-1.docker.io) + if regURL.Hostname() == "index.docker.io" { + regURL.Host = "docker.io" + } + if err != nil { return "", err }