&quot“ docker build - pull” vs“ docker拉$ my_image& amp; docker build $ my_image&quot&quot
我已经阅读了Docker文档,但我不明白是否 - 拉动
选项pulls 我的图像(如果它是之前已经构建的),或者此选项仅拔下我的基本图像我在我的Dockerfile中使用。
我当前的代码:
- docker pull $MY_IMAGE
- docker build --pull --target deploy --cache-from $MY_IMAGE -t $MY_IMAGE .
正在调用docker pull $ my_image
如果我有-
dequeintion ?docker build build
命令中的pull
我的代码应该像:
- docker build --pull --target deploy --cache-from $MY_IMAGE -t $MY_IMAGE .
吗?
目的是什么是我的主要目标
我需要确保我的图像(可能已经构建的也许已经构建),并且最新的 。代码>。
I've read Docker documentation and I do not understand whether --pull
option pulls my image (if it was already built before) or this option only pulls base images that I use in my Dockerfile.
My current code:
- docker pull $MY_IMAGE
- docker build --pull --target deploy --cache-from $MY_IMAGE -t $MY_IMAGE .
Is calling docker pull $MY_IMAGE
redundant if I have --pull
in the docker build
command?
Should my code be like:
- docker build --pull --target deploy --cache-from $MY_IMAGE -t $MY_IMAGE .
?
What is my main goal
I need to make sure that my image (that maybe was already built before) is available and up-to-date for further using in --cache-from
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您运行
docker build -t“ $ my_image”。
,它将始终构建一个新的图像(或重复使用缓存的映像),并使用$ my_image
标记它。您以前Docker拉“ $ my_image”
的任何东西都会丢失其名称(假设它是另一个图像)。在构建新图像之前,没有理由将图像的旧版本拉动。
Docker build -Pull
选项从 line(s)中拉出dockerfile的中的图像。这可能很有用,因为
ubuntu:20.04
或python等图像:3.10
确实会定期获取安全更新和补丁发布,并且(假设您已经具有网络连接性),如果您已经很便宜)具有最新版本的基本图像。If you run
docker build -t "$MY_IMAGE" .
, it will always build a new image (or reuse a cached image) and tag it with$MY_IMAGE
. Anything that you had previouslydocker pull "$MY_IMAGE"
will lose its name (assuming it was a different image).There's no reason to pull an old build of your image before you build a new one.
docker build --pull
option pulls the image(s) in your Dockerfile'sFROM
line(s). This can be useful since images likeubuntu:20.04
orpython:3.10
do regularly get security updates and patch releases, and (assuming you have network connectivity) it's inexpensive if you already have the most recent version of the base image(s).Docker build -pull
将始终尝试找到基本图像的最新版本。它将使用您的缓存图像和(或)Dockerfile图像基本图像和标签。例如,如果您使用自己的映像,它将尝试从存储库中提取较新的层,
例如,如果您使用的是Ubuntu,它将尝试使用已推动的最新或层。
为了您的目标,我看到的目的使您能够搜索可能发布并将其拉动的新层,而无需指定当前版本。 - 使您保持最新状态。
The
docker build --pull
will always try to find the newest version of the base image. It will use your cached image and (or) your dockerfile image base image and tag.If you use your own image for example, it will try to pull newer layers from your repository,
If you are using Ubuntu for example, it will try to use the latest or layer that's been pushed.
For your goal this purpose for what I see gives you the ability to search for new layers that might be published and pull them without specifying the current version. - keeping you up to date.