19

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

Web application goes under tremendous changes and have to update the stack everytime web docker changes. Once in a while there will be updates to Elasticsearch image.

When i run docker stack deploy, it goes and restarts all existing docker services which are not even changed. This hampers whole stack and there is a downtime for whole application. Docker stack does not have option of update.

Someone has solution for this?

Sunil Agarwal
  • 4,097
  • 5
  • 44
  • 80

3 Answers3

12

docker service update --image does the trick.

Check the docker service update docs.

kenorb
  • 155,785
  • 88
  • 678
  • 743
herm
  • 14,613
  • 7
  • 41
  • 62
  • 2
    docker service will update individual image. Everytime i need to specify which image needs to be updated. That will be really painful task. – Sunil Agarwal May 18 '17 at 15:38
  • 1
    Am looking for solution wherein docker stack just updates the images which are modified and not the whole stack – Sunil Agarwal May 18 '17 at 15:38
  • 1
    When I do docker stack deploy uneffected containers do not change. Could it be that you pulled newer versions of the images on your machine? But the only way I know that allows you to be 100% sure only one service is affected is docker service update... – herm May 19 '17 at 13:38
  • 1
    This works for me. `docker service update --image demo.net/library/cf demo_web` – Leo Lee May 07 '19 at 03:44
  • `docker stack deploy` updates not only images, but environment variables, networks, etc. – FiftiN Oct 16 '22 at 08:01
3

Redeploying the stack with changed configuration(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 a stack from a compose or a dab file on the swarm." Also i dont see any command like 'docker stack update '. So this can solve the problem.

Amit Dighe
  • 77
  • 6
1

If you have docker stack created from compose.yml and you need to re-deploy only one service from stack, just do this:

docker service rm <your-service>

and then:

docker stack deploy -c compose.yml <stack-name>

And you just will update your stack, not recreate all services.

Ruby
  • 11
  • 1