How to update the docker stack without restarting all services

I have a swarm cluster in which various technology dockers are deployed. (Zookeeper, Kafka, Elastic, Storm and a custom web application)

The web application comes under huge changes and needs to update the stack every time there is a change in the web docker. Elasticsearch images will be updated from time to time.

When I start the deployment of the docker stack, it starts and restarts all existing dockers that are not even modified. This prevents the creation of the whole stack, and there is downtime for the entire application. The Docker stack is not upgradeable.

Does anyone have a solution for this?

+9
source share
3 answers

docker service update --image does docker service update --image thing.

Check the workflow of docker service update .

+4
source

Redeploying the modified configuration stack (docker-compose.yml file) solves the problem, see https://docs.docker.com/engine/reference/commandline/stack_deploy/#extended-description . There they stated: " Create and update the stack from the compose or dab file on the swarm." Also I do not see any commands, such as "docker stack update". So this can solve the problem.

+2
source

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.

0
source

All Articles