docker - 如果我已经有一个旧的 xx 图像推送,如何获得带有 xx 标签的图像的最后一次推送?
问题描述
2019年,我做了一个Python 3.6的拉图。在那之后,我确定图像是自我更新的(我没有积极使用它,我只是希望自己从存储库中拉出最新的推送或类似的东西),但是当我不小心注意到下载时我很惊讶/创建日期为 2019 年。
问:图像拉取如何工作?是否有标志以便在每次构建图像时检查层哈希/其相关性*?也许有一种方法可以通过 docker daemon 配置文件来设置这个检查?还是我每次都必须删除基础图像才能获得新图像?
我想要什么:所以每次我构建我的图像时,都会检查基础图像是否在 docker hub 存储库中进行最后一次推送(图像的发布)。
注意:我说的是具有相同标签的图像。另外,我不害怕重新构建我的图像,没有任何目的要保存它们。
谢谢。
解决方案
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.
推荐阅读
- java - 如何将下拉值存储到我的表中,以便显示选择的值?
- c - 工作队列启动、中断且从未完成导致 CPU 停顿
- if-statement - 如何用同一行的最大值划分一行的每个单元格
- javascript - jsPDF addImage 返回具有多个图像的相同图像
- php - 浏览器在后台触发 cli 脚本
- html - 我可以将数据从一个 HTML 文件发送到另一个文件吗?
- angular - 在 canDeactivate 方法中添加导航
- docker - 在 docker 中运行 ansible
- sql - 为唯一保单编号创建的案例编号之间至少间隔三个月
- c# - 在 ConfigureServices() 中调用 BuildServiceProvider() 的成本和可能的副作用是什么