I have a bash script that I wrote to update the stack. I just do it on one of the managers. This will force the services to be updated on the stack one by one.
#!/bin/bash # ${1} Stack Name # ${2} Replicas (Number) services=$(docker stack services -q ${1}) if [ ${2} ]; then replicas="--replicas ${2}" else replicas="" fi for service in $services; do docker service update --with-registry-auth --force $replicas $service done
Command execution example.
$ ./updateStack.sh my-stack-name 4
If you do not pass the replica number, this will force the upgrade of all services, but will not change your replicated services.
source share