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:
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?docker push
command, how does Docker know which (tagged/versioned) container to publish?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).