mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-22 14:05:19 +02:00
fix: default tagless Docker image pulls to the latest tag
The daemon pulls every tag of a repository when the tag parameter is empty. The docker CLI never hits this because it adds :latest before calling the API, so only raw API callers do. Pulling "debian" through the API downloaded dozens of images until the registry rate limit stopped the pull. Pass tag=latest when the reference has no tag and no digest. Only a ':' after the last '/' counts as a tag separator: before it, it is a registry port (e.g. registry:5000/repo). This covers both the /docker/images/pull route and the automatic pull fallback when a node image is missing.
This commit is contained in:
2 files changed
+41
-3
No files matched your search
@@ -407,6 +407,14 @@ class Docker(BaseManager):
|
||||
except DockerHttp404Error:
|
||||
pass
|
||||
|
||||
params = {"fromImage": image}
|
||||
if "@" not in image:
|
||||
# Without a tag or digest the daemon pulls every tag of the
|
||||
# repository. Only a ':' after the last '/' is a tag separator:
|
||||
# before it, it is a registry port (e.g. registry:5000/repo).
|
||||
if ":" not in image.rpartition("/")[2]:
|
||||
params["tag"] = "latest"
|
||||
|
||||
try:
|
||||
# The daemon streams progress lines for the whole pull: an idle
|
||||
# socket read for a minute means the registry is unreachable and
|
||||
@@ -414,7 +422,7 @@ class Docker(BaseManager):
|
||||
response = await self.http_query(
|
||||
"POST",
|
||||
"images/create",
|
||||
params={"fromImage": image},
|
||||
params=params,
|
||||
timeout=aiohttp.ClientTimeout(total=None, sock_read=PULL_IDLE_TIMEOUT),
|
||||
)
|
||||
except DockerHttp404Error as e:
|
||||
|
||||
Reference in new issue
Block a user