“ docker build --pull”的目的是什么? [英] What's the purpose of "docker build --pull"?

查看:976
本文介绍了“ docker build --pull”的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建docker映像时,通常使用 docker build。

When building a docker image you normally use docker build ..

但是我发现您可以指定-pull ,因此整个命令看起来像 docker build --pull。

But i've found that you can specify --pull, so the whole command would look like docker build --pull .

我不确定-pull 的目的。 Dockers 官方文档说:始终尝试提取图像的新版本 ,我不确定在这种情况下这意味着什么。

I'm not sure about the purpose of --pull. Dockers official documentation says "Always attempt to pull a newer version of the image", and i'm not sure what this means in this context.

您使用 docker build 来构建新的图像,并最终将其发布到容器注册表的某个位置。您为什么要提取尚不存在的东西?

You use docker build to build a new image, and eventually publish it somewhere to a container registry. Why would you want to pull something that doesnt exist yet?

我希望可以在网络上轻松找到简单的东西,但似乎没人能找到有与此类似的问题。 Google上唯一真正的成功是指Dockers官方文档,我(如上所述)不理解。

I'd expect something as "simple" as this to be easily found on the web, but no one seem to have a similar question as this one. The only real hit on google refers to Dockers official docs, which I (as stated above) dont understand.

感谢您的帮助!

推荐答案

它将提取任何基本映像的最新版本,而不是重复使用您已经在本地标记的内容

it will pull the latest version of any base image(s) instead of reusing whatever you already have tagged locally

例如,基于移动标签(例如 ubuntu:bionic )的图像。上游会进行更改并定期重建它,但是您可能在本地拥有一个月的映像。码头工人会很乐意根据旧基地建造。 -拉会产生副作用,因此您将根据最新的基本图像进行构建

take for instance an image based on a moving tag (such as ubuntu:bionic). upstream makes changes and rebuilds this periodically but you might have a months old image locally. docker will happily build against the old base. --pull will pull as a side effect so you build against the latest base image

通常最好练习使用它来尽快获取上游安全修复程序(而不是使用陈旧的,可能易受攻击的映像)。尽管您必须权衡重大更改(如果您使用不可变标签,则不会有所作为)

it's ~usually a best practice to use it to get upstream security fixes as soon as possible (instead of using stale, potentially vulnerable images). though you have to trade off breaking changes (and if you use immutable tags then it doesn't make a difference)

这篇关于“ docker build --pull”的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆