Search code examples
dockerdockerhub

dockerhub specify latest tag


I have a dockerhub repository where I periodically pull my images, when I need to pull them I noticed that if I specify the version tag:

docker pull cccnrc/diagnosticator-asilo:0.2

everything works fine, but if I try the version-less command it tells me that latest is not specified:

docker pull cccnrc/diagnosticator-asilo

### response
Using default tag: latest
Error response from daemon: manifest for cccnrc/diagnosticator-asilo:latest not found: manifest unknown: manifest unknown

I tried to google around, to look at Docker-Manifest, here etc. but couldn't find a way to understand how do I tell Dockerhub which image must be considered latest. Does anybody know how? Do I need to create an image tagged as latest and replace it every time I update the image?


Solution

  • You can omit the tag, and build your image as

    docker build -t cccnrc/diagnosticator-asilo .
    

    This way it's going to automatically tag it as the latest, you need one little extra step if you want to "version" your image, by tagging it with the actual version

    docker tag cccnrc/diagnosticator-asilo cccnrc/diagnosticator-asilo:0.2
    

    Then you can push both to your docker hub repository

    docker push cccnrc/diagnosticator-asilo
    
    docker push cccnrc/diagnosticator-asilo:0.2
    

    So you can pull a specific version, or just omit the version and pull the latest

    Latest:

    docker pull cccnrc/diagnosticator-asilo
    

    Version 0.2:

    docker pull cccnrc/diagnosticator-asilo:0.2
    

    Of course, you have to do this every time you build a new version

    You can also choose not to version your images or push only the latest without the version number... but that's up to you