I'm using Docker Swarm, and I have condition: always
in the restart_policy
of my compose file, so my services are started automatically when the system reboots or the Docker daemon is restarted.
What I'm trying to achieve is to also have the services pull and run the latest image when the system reboots or the daemon is restarted. This is for an IoT device, so yes, I really do want to do this.
Now, if I manually take down and restart the stack, or if I use docker service update --force --image my-image:latest my-service
, then the latest image is pulled and ran. But if I restart the system, it just keeps running the old image, and doesn't pull the latest one.
I could work around this by removing the restart policy and using systemd to manage lifecycle instead, but I really don't want that extra hassle or complexity, and I'm not even sure how to work that to restart services that crash.
Is there some way to achieve this with Docker Swarm alone?