dockertags

How to create named and latest tag in Docker?


Supposed I have an image that I want to tag as 0.10.24 (in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build and by providing a tag using the -t parameter.

I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.

So far, so good. This works great and fine and all is well.

But, and this is where problems start, I also want to always have the newest image tagged as latest additionally. So I guess I need to give two names to the very same image.

How do I do this? Do I really need to re-run docker build on the exact same version again, but this time use another tag, is is there a better option?


Solution

  • You can have multiple tags when building the image:

    $ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
    

    Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t