Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker service update vs docker stack deploy with existing stack

I have a doubt in using docker swarm mode commands to update existing services after having deployed a set of services using docker stack deploy. As far I understood every service is pinned to the SHA256 digest of the image at the time of creation, so if you rebuild and push an image (with same tag) and you try to run a docker service update, service image is not updated (even if SHA256 is different). On the contrary, if you run a docker stack deploy again, all the services are updated with the new images. I managed to update the service image also by using docker service update --image repository/image:tag <service>. Is this the normal behavior of these commands or is there something I didn't understood?

I'm using Docker 17.03.1-ce

like image 595
Alessandro Dionisi Avatar asked Apr 03 '17 11:04

Alessandro Dionisi


People also ask

What happens by default when a docker service image is updated?

By default, when an update to an individual task returns a state of RUNNING , the scheduler schedules another task to update until all tasks are updated. If, at any time during an update a task returns FAILED , the scheduler pauses the update.

What is docker stack service?

The docker stack can be used to manage a multi-service application. It also moves many of the options you would enter on the docker service into the . yml file (such as docker-cloud. yml or docker-compose. yml) for easier reuse.

What does docker stack deploy do?

When running Docker Engine in swarm mode, you can use docker stack deploy to deploy a complete application stack to the swarm. The deploy command accepts a stack description in the form of a Compose file. The docker stack deploy command supports any Compose file of version “3.0” or above.

What is the difference between Docker compose and docker stack?

Docker stack does not support docker-compose. yml files which are written according to the version 2 specification. It has to be the most recent one, which is 3 at the time of writing, while Docker Compose still can handle versions 2 and 3 without problems.


1 Answers

Docker stack deploy documentation says: "Create and update a stack from a compose or a dab file on the swarm. This command has to be run targeting a manager node." So the behaviour you described is as expected.

Docker service update documentation is not so clear but you yourself said it only runs with --image repository/image:tag <service> so the flag is necessary to update the image.

You have two ways to accomplish what you want.

like image 128
herm Avatar answered Oct 08 '22 14:10

herm