docker compose pull won't refresh images with :latest tag
Situation
A simple docker + compose lifecycle.
I already have a docker compose up running with that very service. I want to update it.
docker build . -t localhost:5000/my-service:latest --load
docker push localhost:5000/my-service:latest
What happens
Without the --load nothing will happen. Nothing is built, nothing pushed, and the registry will have the same image as before.
If I do --load, what happen is that my docker images goes from this:
localhost:5000/my-service latest f06b80c781bf
to this:
localhost:5000/my-service latest c2698fdb10ea
localhost:5000/my-service <none> f06b80c781bf
This is a little confusing, especially as I use the --load as the build command did advice it, but it's not even documented.. https://docs.docker.com/engine/reference/commandline/build/
What happens
I run
docker compose pull
docker compose restart my-service
But then the old version is running. Pull had no effect at all.
In fact a docker ps will show me
842c2c85820d f06b80c781bf Up 4 minutes (unhealthy)
So now the service is unhealthy and does not have a name anymore. This is despite I can use it properly...
So in the end, this method makes a lot of confusion and is unreliable.
What I expect
I expect a simple build (without --load) and push will always override the existing image by default, or at least I can have a --force option in the push. This should be the default behavior for the :latest tag.
Then I expect docker compose pull to download the latest version on the repo. Finally, but that's probably what's happening, the docker compose restart service to restart the latest images pulled by the composer.
Even better:
docker compose restart service --force-pull
or even better
services:
datalake:
image: 'localhost:5000/my-service:latest'
pull: 'always'