Restart a single service in the docker stack

Does anyone know if there is a way for the docker router to restart one service that is part of the stack without restarting the entire stack?

+44
source share
4 answers

Executing docker stack deployagain for me is the way to upgrade services. As Answer by Francois , as well as in my own experience, it updates only those services that need to be updated.

But sometimes it seems that itโ€™s easier to test the material just to restart one service. In my case, I had to clear the volume and update the service to start it as if it were fresh. I am not sure if there is a flaw in the method that I will describe. I tested it in my development stack and it worked fine for me.

Get the identifier of the service you want to demolish, then use docker service update --force <id>it to force a service update that will effectively redeploy it.

$ docker stack services <stack_name>
ID                  NAME              ...
3xrdy2c7pfm3        stack-name_api    ...

$ docker service update --force 3xrdy2c7pfm3

The flag --forcewill cause the service to update, causing it to reboot.

+56
source

Scale to 0 and backup:

docker service scale myservice=0
docker service scale myservice=10
+40
source

- docker stack:

compose dab

: docker stack , docker compose. . , docker stack deploy , :

docker stack process

, , .

... , , ( ), , .

service update , , .

You can also refer to this similar SO QA .

+8
source

remove this:

docker stack rm stack_name

redeploy it:

docker stack deploy -c docker-compose.yml stack_name
0
source

All Articles