patterndockerMinor
What are best practices for docker tag versioning?
Viewed 0 times
whattagaredockerpracticesforversioningbest
Problem
I've recently hooked our CI servers up to build docker images upon git commit.
We have about 8 different containers that get built, each with their own language / frameworks. Some are node and have a package.json, others are python services that contain no semantic version information.
My question is not about how to create tags, its about creating the values for the tag.
How to ensure that each tag has a unique semantic version number for the specific images? Who should be the authority on tracking / incrementing a build version?
We have about 8 different containers that get built, each with their own language / frameworks. Some are node and have a package.json, others are python services that contain no semantic version information.
My question is not about how to create tags, its about creating the values for the tag.
How to ensure that each tag has a unique semantic version number for the specific images? Who should be the authority on tracking / incrementing a build version?
Solution
I would direct you to my post Coupling docker registry and source control where dmaze answered from the official forums.docker.com. Commit hash and branch name or tags suffices.
In your Dockerfile, use a LABEL to record the source of the build. That probably includes the commit hash from distributed source control (git, Mercurial), the branch name if relevant, any release tags if present, and possibly details like the timestamp of the last commit. docker history and docker inspect should be able to show these.
When you docker push your images, push them at least twice, with the commit hash and with the branch name as the “version” part (quay.io/mycorp/imagename:123abc7, quay.io/mycorp/imagename:dmaze-test). If release tags are readily available, the CI system should push images with these tags too.
We are currently using a combination of branch name/commit hash. For us that seems to be enough. timestamps while they are useful IMO just add clutter as they don't provide anything the commit hash doesn't.
I agree with 030 regarding:
who should be the authority on tracking / incrementing a build version
100% is responsibility of the CI to maintain such things, with proper communication between other teams.
In your Dockerfile, use a LABEL to record the source of the build. That probably includes the commit hash from distributed source control (git, Mercurial), the branch name if relevant, any release tags if present, and possibly details like the timestamp of the last commit. docker history and docker inspect should be able to show these.
When you docker push your images, push them at least twice, with the commit hash and with the branch name as the “version” part (quay.io/mycorp/imagename:123abc7, quay.io/mycorp/imagename:dmaze-test). If release tags are readily available, the CI system should push images with these tags too.
We are currently using a combination of branch name/commit hash. For us that seems to be enough. timestamps while they are useful IMO just add clutter as they don't provide anything the commit hash doesn't.
I agree with 030 regarding:
who should be the authority on tracking / incrementing a build version
100% is responsibility of the CI to maintain such things, with proper communication between other teams.
Context
StackExchange DevOps Q#1508, answer score: 7
Revisions (0)
No revisions yet.