What's the Best Way to Update a Service in Docker Swarm Without Downtime?

February 16, 2026 3 answers
Asked by far-and-away
I'm currently using Docker Swarm on a single machine to perform no-downtime updates for my website. Here's my process: 1. I publish a new Docker image tagged as "latest" from my dev machine. 2. On the server, I run "docker pull myimage:latest" but notice that my running container's image changes from "latest" to the previous image's hash. 3. Then, I execute the command "docker service update --image myimage:latest myservicename" and the console shows: overall progress: 1 out of 1 tasks 1/1: running [==================================================>] verify: Service myservicename converged In Portainer, I see that my service has been updated to the latest version of the container, but Docker doesn't attempt to stop the old container or restart the new one. The old container remains running, and the latest image shows as "Unused." I expected Docker to start a new container and redirect traffic to it. What am I missing?

Answers

sieve size
It looks like the issue stems from using the "latest" tag for your images. Docker Swarm doesn't recognize that there's an actual change in the service definition because both the old and new images are tagged as "latest." Ideally, you should use unique tags for your images, like version numbers or timestamps, which will help Docker realize that thereโ€™s a new image to pull and deploy.
Reply to this answer
something_to_consider_
Another option to consider is using `docker stack deploy`, which will automatically fetch the correct image and restart the service if necessary, even when using the "latest" tag. It ensures that the deployment reflects the latest updates in your images.
Reply to this answer
mAiLbOx flap
If you want a quick workaround, you can use the `--force` option with your update command. This will force Docker to recreate the containers and, in doing so, switch them to the latest image.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions