gpt4 book ai didi

docker - 如何始终使用最新版本的 Docker 基础镜像?

转载 作者:行者123 更新时间:2023-12-02 02:50:47 25 4
gpt4 key购买 nike

例如,我有一个 DockerFile,其中包含以下行以提取基本镜像:

FROM myHub.com/base-image

我没有指定使用哪个标签。现在,让我们说一个较新的图像 base-image被插入集线器(版本 2)。如果我运行 docker build同样,docker 发现我的本地系统已经拉取了基本镜像,因此它使用缓存并保留(版本 1)。

快速修复是我指定标签:
FROM myHub.com/base-image:2.0

但这似乎不是很有效。因为当再次推送新版本时,我将不得不手动更改 dockerfile 中的标签。有没有更好的方法来处理这个问题?我是 Docker 的新手,所以有很多我不熟悉的地方。谢谢

最佳答案

解决方案:

docker build --pull

解释:

--pull Always attempt to pull a newer version of the image



https://docs.docker.com/engine/reference/commandline/build/

关于docker - 如何始终使用最新版本的 Docker 基础镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52345748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com