-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix podman search for docker.io/library images #2133
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I could see an argument that “search is just submitting the term to the remote API and we make no guarantee about what it means, anyway, so making edits can only be counterproductive” — but, on balance, finding images is more convenient than not finding images, and, meh, we already have a special case for docker.io
. So, sure, let’s do it.
docker/docker_client.go
Outdated
@@ -363,6 +363,8 @@ func SearchRegistry(ctx context.Context, sys *types.SystemContext, registry, ima | |||
hostname := registry | |||
if registry == dockerHostname { | |||
hostname = dockerV1Hostname | |||
// On docker.io if image is "library/foo", it's stored under "foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I realize this comment is motivated by the Docker one, still…)
- I don’t know what “stored under” means here (the Docker code says “stored locally”, which is even more confusing).
docker.io/library/busybox
anddocker.io/busybox/busybox
would be different names, so it’s can not really be true that thelibrary
one is “stored under” the other one — and anyway where an image is stored on a registry an internal registry detail, ~irrelevant to invoking a search. - What we care about is that (as of today, Oct 2023) a search term of
library/foo
does not find thelibrary/foo
image on thedocker.io
servers, which is surprising - and that Docker is modifying the search term client-side this same way, and it seems convenient to do the same thing. So I think the comment should say something like that.
/approve |
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
5176080
to
31bd235
Compare
@mtrmac updated the comment, hope it's OK with you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, thanks!
This PR attempts to fix this issue containers/podman#20230.
Looking at
moby
, it looks like they are doing a hacky trick when we addlibrary
to the image.As seen here:
If the registry is official then we need to trim "library/" from the image name.
Now what registries are set as official? Looking further at the
newIndexInfo
function:If the registry name is set in the configuration we will return it.
Otherwise we return a new IndexInfo which is not official:
Okay, now what is left to understand is: what registries are set to official at the configuration.
Getting here where we create a new ServiceConfig which is used in
newIndexInfo
.This function creates a ServiceConfig and what I was interested in was how the IndexConfigs is set.
It looks like these two functions mutate the IndexConfigs:
loadInsecureRegistries
andloadMirrors
In both of them the only official IndexServer is
IndexName
which is equal todocker.io
.So all in all - only docker.io is the official registry. Thus, to adjust docker behavior in podman, I trimmed the library/ when registry is docker hostname.
/cc @rhatdan