我试图弄清楚如何发布一个版本化的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/webserverThis 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:awesomeWhen 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/webserverHere, 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-SNAPSHOTAnd 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).
更多推荐
发布评论