Is it possible for image to have multiple tags?

牧云@^-^@ 提交于 2019-12-03 01:07:45

You can create multiple tags:

docker tag <id> <user>/<image>:0.2
docker tag <id> <user>/<image>:latest

and push these.

You need to do one push per each version like:

docker tag test:latest <repo>/<user>/test:latest
docker push <repo>/<user>/test:latest

docker tag test:0.2 <repo>/<user>/test:0.2
docker push <repo>/<user>/test:0.2

You can also combine and say the latest version is 0.2 like:

docker tag <repo>/<user>/test:latest <repo>/<user>/test:0.2
docker push <repo>/<user>/test:0.2

So those will point the same image layer.

You can build an image with several tags and then push the image without explicitly specifying a tag. This will push all image tags to your image registry.

Example:

docker build -t reg/user/image:foo -t reg/user/image:latest .

docker push reg/user/image

There are valid reasons for having multiple tags on an image (see OP) but if you are wanting to add tags for informational purposes, you may be better off with image labels.

Docker labels are inside the image rather than applied to it in the registry. This means the labels are immutable and always get copied with the image.

Label Schema defines a list of interoperable labels for things like version, vcs-ref, build-date and others.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!