Docker Swarm Service - force update of latest image already running

longday picture longday · Aug 13, 2016 · Viewed 39.9k times · Source

environment

  • docker 1.12
  • clusted on Ubuntu 16.04

Is there a way to force a rolling update to a docker swarm service already running if the service update is not changing any parameters but the docker hub image has been updated?

Example: I deployed service:

docker service create --replicas 1 --name servicename --publish 80:80 username/imagename:latest

My build process has updated the latest image on docker hub now I want to pull the latest again.

I have tried running:

docker service update --image username/imagename:latest servicename

When I follow this process, docker does not pull the latest, I guess it assumes that since I wanted latest and docker already pulled an image:latest then there is nothing to do.

The only work around I have is to remove the service servicename and redeploy.

Answer

Aisamu picture Aisamu · Jan 27, 2017

Just for future reference:

Docker 1.13 added a --force flag to service update:

--force: Force update even if no changes require it

Use it as in:

docker service update --force service_name