Applying the tag structure in this recipe results in DockerĀ using latest as the version tag. When we build a new version of an image without explicitly providing a version, Docker will move the latest tag to this new image and leave the previous build untagged. The same process will occur with images that we push to Docker Hub. It is generally better practice to use a specific image version tag. By doing this we can maintain a history of our images, which makes any rollback or post incident analysis easier.
Let's tag our adderservice image with a version by running this command:
$ docker tag adderservice <namespace>/adderservice:1
We can now push this image to Docker Hub, like so:
$ docker push <namespace>/adderservice:1
If we navigate on Dockerhub to the Tags panel for our adderservice image we should be able to see that our newly pushed image is available.
Using an incremental build number is one approach to maintaining version tags. Another approach is to pull the version field from package.json and use that as a version tag. Our preferred approach is to use the git SHA as a version tag that we can immediately use to identify the exact code that is built into our service containers.