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 ad 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?
You can have multiple tags when building the image:
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
Variation of Aaron's answer. Using sed without temporary files
Here is my bash script
You can then remove untagged images if you rebuilt the same version with
link
or
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
or individually:
Once you have your image, you can use
Build and tag the image with creack/node:latest
Add a new tag
You can use this and skip the -t part from build
Just grep the ID from
docker images
:Needs no temporary file and gives full build output. You still can redirect it to
/dev/null
or a log file.ID=$(docker build -t creack/node .)
doesn't work for me sinceID
will contain the output from the build.SO I'm using this small BASH script: