See "The misunderstood Docker tag: latest
" from Marc Campbell: latest
is a tag referencing a tag pushed:
Latest is just a tag with a special name.
It doesn’t mean anything special unless you use a pretty specific build/tag/push/pull/run pattern.
“Latest” simply means “the last build/tag that ran without a specific tag/version specified”.
In other words, you could build new versions like this:
sudo docker build -t marc/test .
sudo docker tag marc/test marc/test:2
...
sudo docker build -t marc/test .
sudo docker tag marc/test:3
...
But this is a little odd. Why would I have to tag everything twice?
If you are shipping Docker images to a production environment, you should just ignore the latest
tag.
Don’t use it. Don’t be tempted by it.
It’s easy to look at it and think that your deployment script should just pull “latest” and your build process will ensure that’s valid. It takes a lot of discipline to make that work. Just version your tags. Every time.
See more with "Docker: The latest Confusion" from Adrian Mouat:
If the repository is to be uploaded to the Docker Hub, the repository name must be prefixed with a slash and the Docker Hub user name e.g. amouat/myrepo:mytag
.
The trick is of course, if you leave the tag part out (e.g. docker tag myrepo:1.0 myrepo
), Docker will automatically give it the tag latest
.
See "How to create named and latest
tag in Docker?".
Just because an image is tagged latest, does not mean that it is the most up-to-date image within its repository.
So what happens if you do the pull on a repository with no latest tag?
This:
$ docker pull amouat/myrepo
Pulling repository amouat/myrepo
2015/01/21 12:04:06 Tag latest not found in repository amouat/myrepo
The OP adds:
The issue I had is trying to keep the dev environment synced with latest changes without having to manually edit the docker-compose.yml with the new tag every change.
For that, I always maintain a "deployed" tag which is shifting (applied only when I upgrade an image tag) and used in scripts/docker-compose.yml.
I prefer building my own image in order to add LABEL
s which are used to memorize what that "deployed" tag actually refers to (I setup a LABEL named "tag" with the actual tag name in it).