通过示例发布容器到码头(Publishing Container to Quay by Example)

编程入门 行业动态 更新时间:2024-10-28 02:32:06
通过示例发布容器到码头(Publishing Container to Quay by Example)

我试图弄清楚如何发布一个版本化的Docker容器到Quay.io,并且没有看到如何在他们的文档中这样做。 从文档:

# Login to Quay.io docker login quay.io (will now be prompted for username + password) # Get your <containerID> docker ps -l # Tag that container by <containerId> docker commit <containerId> quay.io/<myUsername>/<myRegistry> # Now publish it to Quay.io docker push quay.io/<myUsername>/<myRegistry>

然而这让我非常困惑:

如果我想用1.0.0-SNAPSHOT或1.0-rc或2.0或3.1.6-GA标记/版本化容器,该怎么办? 我在哪里指定实际的标签名称/版本? 当我运行docker push命令时,Docker如何知道要发布哪个(标记/版本化)容器?

I'm trying to figure out how to publish a versioned Docker container to Quay.io and am not seeing how to do so in their docs. From the docs:

# Login to Quay.io docker login quay.io (will now be prompted for username + password) # Get your <containerID> docker ps -l # Tag that container by <containerId> docker commit <containerId> quay.io/<myUsername>/<myRegistry> # Now publish it to Quay.io docker push quay.io/<myUsername>/<myRegistry>

However this leaves me very confused:

What if I want my containers tagged/versioned with, say, 1.0.0-SNAPSHOT, or 1.0-rc, or 2.0 or 3.1.6-G.A? Where do I specify the actual tag name/version? When I run the docker push command, how does Docker know which (tagged/versioned) container to publish?

最满意答案

首先,值得注意的是,您不会将容器推送到注册表中。 你推送图像 。 您问题中的docker commit命令会根据活动容器创建新映像。

当为图像分配标签时 - 使用更常见的docker tag命令[1],或使用docker commit - 标签的格式为[<registry>/]<repository>[:<tag>] ,其中[...]用于表示选项组件。 举例来说,您可能会在Docker Hub上标记一个定位您的帐户的图片,如下所示:

docker tag smeeb/webserver

这将被分配latest标签,因为你没有明确指定。 要明确地分配标签awesome而不是latest :

docker tag smeeb/webserver:awesome

当您为替代注册表标记映像时,可以将注册表名称作为标记的一部分包含在内,如下所示:

docker tag <imageId> quay.io/smeeb/webserver

在这里, quay.io是注册表, smeeb/webserver是存储库,并且您已经隐式分配了latest标签。 你可以明确地说:

docker tag <imageId> quay.io/smeeb/webserver:1.0.0-SNAPSHOT

等等。 使用docker commit创建图像时可以使用相同的语法。

[1]:我看到使用docker tag的原因比较常见,因为docker commit使用通常被认为是反模式。 使用Dockerfile来创建新图像,这样可以更容易地重现相同的配置(并允许您通过版本控制图像的配置)。

First, it's worth noting that you don't push containers to a registry. You push images. The docker commit command in your question creates new image based on an active container.

When assigning tags to images -- using either the docker tag command, which is more common [1], or when using docker commit -- the format of a tag is [<registry>/]<repository>[:<tag>], where [...] is used to represent an option component. So for example you might tag an image targeting your account on Docker Hub like this:

docker tag smeeb/webserver

This would be assigned the latest tag, since you haven't specified one explicitly. To explicitly assign the tag awesome instead of latest:

docker tag smeeb/webserver:awesome

When you're tagging an image for an alternate registry, you include the registry name as part of the tag, as in:

docker tag <imageId> quay.io/smeeb/webserver

Here, quay.io is the registry, smeeb/webserver is the repository, and you've implicitly assigned the latest tag. You can be explicit instead:

docker tag <imageId> quay.io/smeeb/webserver:1.0.0-SNAPSHOT

And so forth. You can use the same syntax when creating images with docker commit.

[1]: The reason I saw that using docker tag is more common is that use of docker commit is generally considered an anti-pattern. Use a Dockerfile to create your new image, which makes it much easier to reproduce the same configuration (and allows you to version control the configuration of your image).

更多推荐

本文发布于:2023-07-30 23:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   容器   码头   Quay   Container

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!