繁体   English   中英

我如何知道在 Docker 中从哪个注册表中提取图像?

[英]How do I know which registry an image was pulled from in Docker?

在 Docker 我正在运行 DockerFile 设置如下:

# Comment
FROM python:3.8.3

RUN pip install matplotlib

我正在使用以下命令生成此图像:

docker build -t myimage:mytag -f DockerFile.

这是我对它的作用的理解:

  • python:3.8.3映像是从某个远程注册表“拉取”的
  • 一个新的“层”建立在这个基础镜像之上并被标记为myimage:mytag
  • matplotlib 安装在这个新层

我的问题是:有没有办法(以编程方式)确定从哪个注册表中提取基本映像?

注册表:您可以使用以下命令找到您的default注册表:

# docker info | grep -i registry
 Registry: https://index.docker.io/v1/

如果您不指定另一个注册表,它会向您显示 docker 搜索的位置。

示例:从“默认”注册表索引中提取 python:3.8.3.docker.io/v1/

# docker pull python:3.8.3
3.8.3: Pulling from library/python
...
...
...
Status: Downloaded newer image for python:3.8.3
docker.io/library/python:3.8.3

验证图像(您会看到,ImageID 没有后缀):

# docker images | grep -i python
python                               3.8.3               7f5b6ccd03e9        6 weeks ago         934MB

示例:从fedora registry中提取图像nginx

# docker pull registry.fedoraproject.org/f29/nginx
Using default tag: latest
latest: Pulling from f29/nginx
...
Status: Downloaded newer image for registry.fedoraproject.org/f29/nginx:latest
registry.fedoraproject.org/f29/nginx:latest

验证图像(您会看到,ImageID 现在有一个后缀):

# docker images | grep -i nginx
registry.fedoraproject.org/f29/nginx   latest              225d690974f7        20 months ago       368MB

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM