Docker 镜像拉取开始和结束时间或拉取镜像的持续时间

问题描述 投票:0回答:1

我有一个需求,我需要找出拉取 Docker 镜像需要多长时间。为此,我需要找出 docker pull 的开始和结束时间或完全下载所需的总时间。

有什么方法可以在任何 docker 日志中看到这一点吗?我尝试检查检查命令,但没有帮助。

docker docker-registry docker-image
1个回答
0
投票

您可以查询

docker events
来查看图像拉取发生的时间,但不清楚这是开始还是结束,并且只有一个事件,因此您无法获得持续时间:

$ docker events -f type=image -f action=pull --since=0
2023-09-27T21:10:18.215031834-04:00 image pull alpine:latest (name=alpine)

如果您正在运行拉取,那么这根本不需要 docker,只需使用

time
实用程序包装命令即可:

$ time docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a803e7c4b030: Pull complete 
8b625c47d697: Pull complete 
4d3239651a63: Pull complete 
0f816efa513d: Pull complete 
01d159b8db2f: Pull complete 
5fb9a81470f3: Pull complete 
9b1e1e7164db: Pull complete 
Digest: sha256:32da30332506740a2f7c34d5dc70467b7f14ec67d912703568daff790ab3f755
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

real    0m9.369s
user    0m0.049s
sys     0m0.059s

real
时间显示拉取镜像花了9.369秒。

© www.soinside.com 2019 - 2024. All rights reserved.