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

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

问题描述

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

我希望有一天我会有其他版本的图片,所以我将重新运行这个过程,只需要另一个标签名称。



到目前为止,很好。这个工作很好,很好,一切都很好。



但是,这是问题开始的地方,我也希望总是有最新的图片标记广告最新另外。所以我想我需要给同一个图像两个名字。



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

解决方案

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

  $ docker build -t whenry / fedora-jboss:最新的-t whenry / fedora-jboss:v2.1。 

参考: https://docs.docker.com/engine/reference/commandline/build/#tag-image-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.

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.

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 .

Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t

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

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