74

Suppose I have an image me/mystuff:v0.0.1

I find if I push it to the repository:

docker push me/mystuff:v0.0.1 

latest is not created, and on a pull from another machine it will complain, e.g.

ssh me@faraway
(faraway)  $ docker run -it me/mystuff /bin/bash

will result in a not found error for me/mystuff:latest

I can add the latest tag and push explicitly to the public repository:

docker login me
docker tag me/mystuff:v0.0.1 me/mystuff:latest
docker push me/mystuff:latest

and then from another machine:

docker pull me/mystuff

will work because latest exists.

I am also finding that once latest exists, it does not auto update when a new numbered version is pushed.

Can I somehow eliminate this step of manually tagging latest and have latest automatically point to the latest numbered version?

Or is it there for a reason, like allowing the separation of development versions (tagged with a vN.N.N only) from the production version (tagged latest)?

Paul
  • 26,170
  • 12
  • 85
  • 119

1 Answers1

65

The latest is just the default value of the tag if none is specified. If you push a tagged image it does not replace the current image tagged with latest.

Usman Ismail
  • 17,999
  • 14
  • 83
  • 165
  • 14
    is there a command to push it as an tag AND as latest? or do i need two commands for this? eg: docker push foo/bar:v1 docker push foo/bar – Florian Widtmann Feb 12 '15 at 14:13
  • 13
    NOTE: pushing without a tag (ie: `docker push foo/bar`) pushes all the local images marked with repo foo/bar. If one of those has no tag, it'll presumably push a 'latest' tag (as @Usman says). If all your local images are tagged, only those tags get pushed (which may not include 'latest'). Note you can easily create multiple tags on local images as per [this answer](http://stackoverflow.com/a/25214186/420867), eg: create a local 'latest' tag that you can then push. – drevicko Feb 08 '17 at 15:21
  • 16
    Surely `docker tag me/mystuff:v0.0.1 me/mystuff:latest` would work and you don't need two tags. – Muhammad Rehan Saeed Oct 16 '17 at 11:00
  • 4
    Also, Docker is smart enough that if you push two tags, and they both have the same underlying hashes, it recognizes it and simply adds the second tag name. – ingyhere Mar 19 '20 at 12:34