首页 > 解决方案 > 如果我已经有一个旧的 xx 图像推送,如何获得带有 xx 标签的图像的最后一次推送?

问题描述

2019年,我做了一个Python 3.6的拉图。在那之后,我确定图像是自我更新的(我没有积极使用它,我只是希望自己从存储库中拉出最新的推送或类似的东西),但是当我不小心注意到下载时我很惊讶/创建日期为 2019 年。

:图像拉取如何工作?是否有标志以便在每次构建图像​​时检查层哈希/其相关性*?也许有一种方法可以通过 docker daemon 配置文件来设置这个检查?还是我每次都必须删除基础图像才能获得新图像?

我想要什么:所以每次我构建我的图像时,都会检查基础图像是否在 docker hub 存储库中进行最后一次推送(图像的发布)。

注意:我说的是具有相同标签的图像。另外,我不害怕重新构建我的图像,没有任何目的要保存它们。

谢谢。

标签: dockerdockerfiledocker-registry

解决方案


You need to explicitly docker pull the image to get updates. For your custom images, there are docker build --pull and docker-compose build --pull options that will pull the base image (though there is not a "pull" option for docker-compose up --build).

Without this, Docker will never check for updates for an image it already has. If your Dockerfile starts FROM python:3.6 and you already have a local image with that name and tag, Docker just uses it without contacting Docker Hub. If you don't have it then Docker will pull it, once, and then you'll have it locally.

The other thing to watch for is that the updates do eventually stop. If you look at the Docker Hub python image page you'll notice that there are no longer rebuilds for Python 3.5. If you pin to a very specific patch version, the automated builds generally only build the latest patch version for each supported minor version; if your image is FROM python:3.6.11 it will never get updates because 3.6.12 is the latest 3.6.x version.


推荐阅读