dockerdockerfilegoogle-artifact-registry

Docker build using old Docker Image present locally with same tag and different sha when referenced in FROM command in new Dockerfile


I have a base docker image pushed to Google Artifacts Registry tagged us-central1-docker.pkg.dev/proj1/docker/base:v1.1. I have another Dockerfile that uses this base image like

FROM us-central1-docker.pkg.dev/proj1/docker/base:v1.1
CMD [ "/entrypoint.sh" ]

entrypoint.sh is already present in base the base image. I build & push application Docker Image from this Dockerfile.

The base image is now present locally on my system.

Some other dev realized that there was a minor bug in the base image and created a new image with the same tag v1.1 and pushed to Google Artifacts Registry. The new image has a different SHA than the previous image but same tag v1.1

After the change was pushed to the base image, I build & deploy the App Image again and it is still using the old docker image present locally whereas a new Docker image is now present in the Artifacts Repo with a different SHA.

How can I make docker to check if a new image is present with a different SHA?

If I do a docker pull, it sees that a newer image is present and it pulls the latest image with up to date SHA but not if it is being referenced in the FROM command.


Solution

  • Adding --pull flag to the docker build command solves the issue as mentioned in this question.

    It will pull the latest version of any base image(s) instead of reusing whatever is present locally.