I have read this: Re-deploying docker stack not updating containers with latest and as this issue says:
But I still want to use latest anyway, and have swarm check for latest sha digest (or any tag that I reuse every deploy)
Turns out this should work as of 17.06 out of the box. docker stack deploy should pull sha digests from the registry each time. This changed a bit since then, and bugs were fixed, so this is where we're at today:
docker stack deploy -c stack.yml mystack with a 18.06 client and server versions, will turn the latest tag (or lack of tag) in the stack.yml into a sha and send that to the service update command. If the sha digests match, and nothing else in yaml has changed, service will not replace the task.
Stack deploy now has docker stack deploy --resolve-image options, which defaults to always so it should always check the sha digest. never means it will not compare digests from registery or local cash (even if the node image cache has a different version). I can't figure out what changed does.
But why did my test still fail:
I update my image(still use latest tag) and execute docker stack deploy -c test.yml test, but my service did not restart to use the new image to run the container.
Did I misunderstand the issue?
This is test.yml:
version: "3.7"
services:
testapp:
image: testimage
This is docker version:
docker-ce-cli-19.03.5-3.el7.x86_64
docker-ce-19.03.5-3.el7.x86_64