I am planning to increment docker tag automatically using shell script. Right now i am using Date function to insert %m%d%y%H%M for docker tag. Every time, current month year and date with Hours and mins are inserting like 03262016091.
But when I see it in Docker hub, it's not looking good and planning to keep the version names as 1.0.0 or with git commit number.
I am using Travis CI for my continuous Integration but not to build docker images. I have shell script to do that using Docker file.
My Requirement is:
I have to increment below version number everytime when I execute my build.
Version=1.0.0
Could you please help me how to do this?
In reality, latest is used as the default tag when you haven't specified anything else. That's the only time it'll be used – it doesn't automatically refer to the newest image you've built. If you now ran docker run my-image:latest , you'd be using the second image to be built.
In Docker, we can also assign multiple tags to an image. Here, we'll use the docker build command to assign multiple tags to an image in a single command.
Latest is Just a Tag It's just the tag which is applied to an image by default which does not have a tag. Those two commands will both result in a new image being created and tagged as :latest: # those two are the same: $ docker build -t company/image_name . $ docker build -t company/image_name:latest .
You could use the git revision which is unique as well. Most simple solution from the command line is a nested git-rev command:
docker tag <image> <image>:$(git rev-parse --short HEAD)"
gives you e.g.
<image> = myImage >> myImage:67df348
If your repository were named your/project and was tagged with 1.0, then following should rebuild it with tag 1.01:
docker build -t your/project:$(docker images | awk '($1 == "your/project") {print $2 += .01; exit}') .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With