Docker stack "--force-recreate" in swarm mode using compose file

Viewed 5660

Is it possible to do a force recreation of containers using compose file in docker swarm mode ? (I am aware of using HEALTHCHECK in Dockerfile)

Currently i have to remove the stack first & then deploy it again -

$ docker stack deploy -c stg-sm-deploy-compose.yml --with-registry-auth MY-APP

$ docker stack rm MY-APP

$ docker stack deploy -c stg-sm-deploy-compose.yml --with-registry-auth MY-APP

Is there any possibility that above 3 commands can be replaced by -

$ docker stack deploy -c stg-sm-deploy-compose.yml --with-registry-auth MY-APP --force-recreate

3 Answers

An extension of @BMitch's answer, with a little less shell.

$ docker stack services -q $stack \
  | xargs -rt -n1 -- docker service update --force
...
Related