<p>i need small help. 
What is the best option for tagging docker images. I am looking to make bash script. Is that recommended or is there any different solution? 
I would like to add a way to tag my docker images generated by the jenkins build step.
I need to auto-increment the BuildNumber, but to manually set the MajorVersion and MinorVersion.</p>

<p>I can't find any example related to this. Could you provide me any example to manage my version numbers. </p>

<p>In my experience, it's not a very good practice to tag your images with build numbers as part of your image "version". <a href="https://semver.org/" rel="noreferrer">As stated in SemVer</a>, the third part of the version number is the "Patch", representing a non-breaking fix.</p>

<p>The problem with just adding a build number as the patch version is that you aren't necessarily  representing a patch with every build. For example, imagine you're working on a fix (which will get released as a patch version). But you don't nail that fix correctly on your first commit/push to your working branch. That first build will already be a build-number increment, as will any other pushes from other devs to other branches. And this will all depend on how your CI is set up.</p>

<p>If you <em>need</em> to put the build number, then you can use your CI build number (I think all CI solutions provide that) and add them to your tag as a fourth element in the semver (e.g.: <code>2.4.1-2312</code>, where <code>2312</code> is the build number), and once it gets released you can bump the tag to <code>2.4.2</code>.</p>

<p>If you want to be compliant with the docker usual practices, you should also tag <code>2.4.2</code> as <code>2.4</code>, <code>2</code> and <code>latest</code>, if you're to release it.</p>

<p>My last advise would be to always tag an image with the full SHA of the commit you're building, as there's no easier way for matching an image to a point in time in your codebase.</p>
