Reputation: 526
Fairly new Docker user here.
Say I have several versions of a docker image, with the latest two being myimg:1.0.0
and myimg:2.0.0
. myimg:2.0.0
is also tagged as myimg:latest
, whereas before that one was created, myimg:1.0.0
was also tagged as myimg:latest
.
Is there a way to point to the second-to-last :latest
tag, without specifying the exact version (i.e. :1.0.0
in this example)? Or for that matter, is there some history of which image corresponds to :latest
that one can go through to find a the image that corresponded to :latest
N versions ago?
The reason I am asking is that I would like to run two succeeding versions of an image alongside each other, so the latest and second-to-latest are always used. I know this is possible by specifying the exact versions, but I'm hoping to make use of :latest
somehow.
Upvotes: 1
Views: 1236
Reputation: 11
With debian
you have the :oldstable
tag to use the previous stable version, and the :oldoldstable
for the "previous previous" stable version.
Maybe there are equivalents with other distros.
I found the tag here: https://www.debian.org/releases/index.en.html
Upvotes: 1
Reputation: 870
:latest
is just a name. There is absolutely nothing special with it. It only gets updated when the tag of the Docker image you built was latest
or was omitted. There is NO guarantee that :latest
always points to the latest version of an image.
So it's simple to imagine that there's no simple way to get the second last image like git's HEAD~1. The only way you could do it is via version control.
My personal opinion: tag your images with a version tag.
Upvotes: 3