如何在 Docker 中创建命名和最新标签? [英] How to create named and latest tag in Docker?

查看:32
本文介绍了如何在 Docker 中创建命名和最新标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个图像想要标记为 0.10.24(在我的例子中它是一个包含 Node.js 0.10.24 的图像).我使用 Dockerfile 并执行 docker build 并通过使用 -t 参数提供标签来构建该映像.

Supposed I have an image that I want to tag as 0.10.24 (in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build and by providing a tag using the -t parameter.

我希望有一天我会有该图像的其他版本,因此我将重新运行该过程,只是使用另一个标签名称.

I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.

到目前为止,一切都很好.这很好用,一切都很好.

So far, so good. This works great and fine and all is well.

但是,这就是问题开始的地方,我还希望始终将最新的图像标记为 latest 附加广告.所以我想我需要给同一个图像取两个名字.

But, and this is where problems start, I also want to always have the newest image tagged ad latest additionally. So I guess I need to give two names to the very same image.

我该怎么做?我真的需要再次在完全相同的版本上重新运行 docker build,但这次使用另一个标签,有没有更好的选择?

How do I do this? Do I really need to re-run docker build on the exact same version again, but this time use another tag, is is there a better option?

推荐答案

构建镜像时可以有多个标签:

You can have multiple tags when building the image:

$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .

参考:https://docs.docker.com/engine/reference/命令行/构建/#tag-image-t

这篇关于如何在 Docker 中创建命名和最新标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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