Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

170
Views
Docker registry will not update images

I've set up a docker registry on a remote system. I've pushed some images to it. I've made changes to these images and want to update these images so when I pull them I get the most recent version. How can I guarantee I always get the newest version?

I tried to tag my image with :latest, but that doesn't seem to do anything. I also ensured the image gets built anew with the --no-cache flag.

This is what I do at the moment:

I build an image via

docker image build --tag karaf .

I tag that image with

docker image tag karaf outserver.at:5000/karaf

I push that image with

docker push outserver.at:5000/karaf

I pull the image on some destination system via

docker pull outserver.at:5000/karaf

I start my docker-compose file which has these images as services via

docker-compose up

I would expect the push command to just overwrite the existing image on the registry with the newer image. Logically, if I pull that image on the destination system, I would expect the image to be updated. But actually, the image I get is outdated.

10 months ago · Santiago Trujillo
2 answers
Answer question

0

Best practice is generally to be explicit in your docker run and similar commands: use a unique tag for every image build (like a date stamp, source control commit ID, or build number), use that specific version/build number when you’re deploying, and don’t rely on things like the latest tag.

The trick here is that if you docker run someimage:latest, Docker first starts by looking at its local list of images. If it already has something with that exact name and tag, it just runs it; if not, it will implicitly docker pull first. This extends to higher-level orchestration systems too (you have to go fairly far out of your way to get Kubernetes to force it to reload an image, for example).

In the case of Docker Compose, docker-compose up tries to bring the system into an expected state, doing the minimum work necessary. If you change the tag on your application container then docker-compose up will delete and recreate that one container without touching your database container. In addition to the manual docker pull you’re doing, you might need to docker-compose stop app; docker-compose rm app to force the one container to be rebuilt.

10 months ago · Santiago Trujillo Report

0

If your push command genuinely worked and you successfully pushed a new image to your registry, then pulling the image as you're doing will work and you will end up with the newer image.

Check (via looking at the return code) that the push worked successfully (below shows Bash):

> docker push outserver.at:5000/karaf
> echo $?

If you are not seeing this then please show us the console messages for the build, tag, push and pull steps.

IMPORTANT:

Note that the :latest tag has nothing to do with the latest image in the registry! A tag is simply a string that is associated with an image: in this case, the string is made up of the letters l, a, t, e, s and t, it does not necessarily mean that the tag is the latest image. The :latest tag is overwritten in 2 circumstances:

  1. You explicitly use the tag when pushing, e.g. docker push outserver.at:5000/karaf:latest.
  2. You specify no tag at all, e.g. docker push outserver.at:5000/karaf.

If you push an image with no tag (thereby overwriting the latest tag in the registry), followed by pushing a newer image but specifying a tag, then the :latest tag will not be overwritten and will point to the first image, not the newer one.

Best practice is to always specify an image tag: never use the :latest tag.

10 months ago · Santiago Trujillo Report
Answer question
Find remote jobs