Search code examples
dockeraws-ecrdocker-pull

docker pull wouldn't pull latest image from remote


I ran this:

docker pull 91xxxxx371.dkr.ecr.us-west-2.amazonaws.com/main_api

and nothing new was pulled, but I knew there were new images on AWS/ECR. So I removed the existing images:

docker rmi 91xxxxx371.dkr.ecr.us-west-2.amazonaws.com/main_api

and then pulled again and of course it says it retrieved new images, but that's probably just because I deleted the local tags/images or whatever.

Why didn't the first pull command get the latest? It defaults to the latest tag.


Solution

  • Update: I have to correct my answer, @David Maze (comment) is right: I described the docker run behaviour.

    From the Docker documentation:

    When using tags, you can docker pull an image again to make sure you have the most up-to-date version of that image

    So your command should work, I don't know why it's not working, sorry. But nevertheless you can use as a workaround tags to enforce to pull the image with the specified tag.


    docker run (not docker pull) search first in your local registry on your machine. If there is the image with the tag latest, the search is satisfied and terminated. If the image with the given tag is not available in your local registry, then docker will search in a remote registry like docker hub or your own.

    So the tag latest should be used with care. If you have an Image with the tag latest in your local registry then you have to delete it first, so docker get nothing and search in remote registry.