title: Properly Versioning Docker Images
body: <p>Following on the 4-year-old question 
  <a href="https://stackoverflow.com/questions/32098374/">Docker image versioning and lifecycle management</a>, because IMHO it did not address versioning Docker Images <em>properly</em>:</p>
  
  <blockquote>
    <p>I don't find this answer to be adequate, as there can be successive versions of the same tag. We need a way to be able to lock down dependencies onto a particular version of a tag.</p>
  </blockquote>
  
  <p>and also, </p>
  
  <blockquote>
    <p>the answer is to not use <code>latest</code>. </p>
  </blockquote>
  
  <p>The "solution" I found on the web is confusing too. E.g., </p>
  
  <ul>
  <li><a href="https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375" rel="noreferrer">Here</a> it <em>hinted</em> not use <code>latest</code>, and the "solution" <em>hinted</em> to be tagging twice. I emphasize on "<em>hinted</em>" because there is no solid recommendation (to me). </li>
  <li>And <a href="https://medium.com/travis-on-docker/how-to-version-your-docker-images-1d5c577ebf54" rel="noreferrer">here</a> it even shows that we need to do <code>docker push</code> <strong><em>twice</em></strong> on the same image. </li>
  </ul>
  
  <p>So, how to properly versioning Docker Images (both locally and when pushing/publishing to docker hub)? </p>
  
  <p><strong>AMEND:</strong></p>
  
  <p>So far there are two answers. Thanks for that. </p>
  
  <ul>
  <li>Both use git's short version ID.</li>
  <li>And both miss the pushing/publishing part from the answer.</li>
  </ul>
  
  <p>As I <strong><em>do</em></strong> need to push/publish my docker image to Docker repository, and from <a href="https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375" rel="noreferrer">here</a> it <em>hinted</em> that not using <code>latest</code> will give you trouble when pulling the latest, if you go with specific ID tagging. 
  Moreover, using git's short version ID might be a good solution for internal use, but when publishing docker image for public consumption, it then might not be the best solution. </p>