'Docker image/container not updating

I have a docker image, call it dockerimage/test. Every time I update it, I increment a tag, so dockerimage/test:1, dockerimage/test:2 and so on.

When I pull and run the image on my local machine with docker, it works great, and I can see the changes I'm making to the image. However, I also have a VM with docker installed, and when I pull the image on that and run it, it simply shows the old version of the website (i.e. it's like the image hasn't updated, even though docker says it has downloaded a newer version).

I'm wondering if I mistagged an image on the VM, i.e. it's running the wrong image, so I tried removing all the images on the VM, creating a fresh image (i.e. dockerimage/test:3), and running that. Again, works fine on my local machine, just shows the old version on my VM.

I tried clearing my browser cache, making edits to files, making a new registry, restarting the machine, it doesn't make a difference.

At this point, I just want to delete everything associated with this image/container, and get a fresh version. But it looks like docker is storing something so I can't.

I know docker is "smart" about how it handles images - it recognizes duplicate images, files etc. but is there anyway to force a remove of an image, and force a re-download of an image, so it redownloads all the files?



Solution 1:[1]

From the problem described here it seems you aren't creating a new container with the new image.

So just run a new container as soon as you upgrade the image. You can always automate this process. I have continuous deployment pipelines (bitbucket,ansible or jenkins,ansible) doing it for me.

Solution 2:[2]

I think you should try to pull docker image with "--no-cache".

Solution 3:[3]

I finally found the answer to this bugg, for a long time I thought the problem was with docker, but it is not!

The problem is your browser! It is keeping a cache of the website so even if you update the docker image, the browser wont update it right away. You will need to wait for like 10 minutes and refresh the browser or try to open a new one.

To prove my point try to update the image by writing hello world in the home page, then open your browser in private mode and you will see the change right away because private mode doesnt keep a cache.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Qasim Sarfraz
Solution 2 OpsEco
Solution 3 sukeno bekoum