Closed andradei closed 3 years ago
Hi @andradei, yes I confirm this is the case for me. I will look into the source code and help with a PR.
I have checked the issue. It seems the issue related to how the tags (versions) are returned by Docker Hub.
Currently the versions are returned out of order.
I will dig a little bit more.
@mattstauffer, in order to force order to the tags retrieved, we can add order=name
query parameter. For example:
https://registry.hub.docker.com/v2/repositories/library/mysql/tags?ordering=name
This returns the tags in order, like that:
^ Illuminate\Support\Collection^ {#490
#items: array:10 [
0 => "latest"
1 => "8.0.4-rc"
2 => "8.0.4"
3 => "8.0.3"
4 => "8.0.23"
5 => "8.0.22"
6 => "8.0.21"
7 => "8.0.20"
8 => "8.0.2"
9 => "8.0.19"
]
Any thoughts, should I PR it?
Also, another way of doing it, is to refactor this function, I am trying to get my head around it, but not sure why latest
tag is being rejected.
public function getLatestTag(): string
{
$nonLatestTags = $this->getTags()->reject(function ($tag) {
return $tag === 'latest';
});
if ($nonLatestTags->isEmpty()) {
return 'latest';
}
return $nonLatestTags->first();
}
Ah, that order
param is a great idea!
We're rejecting latest
because the whole point of that function is to figure out which tag latest
is referring to.
When leaving docker tag empty (default
latest
) or explicitly typing "latest", it picks the lowest version from Docker Hub instead... Selecting the version explicitly works, however.Note this is downloading
mysql:5.6.51
instead ofmysql:latest
(version8.0.23
as of today)