Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a deployed docker stack?

I just completed the beginners Docker tutorials and would like to know how to clean up.

I deployed a stack and with a few different service using the below command:

docker stack deploy --compose-file docker-stack.yml vote  

Is there away to stop all the containers associated with this stack, or do I have to stop them individually?

like image 834
spw Avatar asked Jan 24 '17 20:01

spw


People also ask

How do I stop docker stacking?

If for some reason you still want the stack and service definitions, you can scale the "replicated" services down to 0 replicas, and "global" services you can add a constraint that doesn't match any node. I just wanted to mention that it can take a while (10-15 seconds) for all of the containers to stop.

How do I stop a docker process?

To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds.

How do I stop a docker Swarm?

Leave the swarmRun the docker swarm leave command on a node to remove it from the swarm. For example to leave the swarm on a worker node: $ docker swarm leave Node left the swarm. When a node leaves the swarm, the Docker Engine stops running in swarm mode.


1 Answers

You can remove a stack with:

docker stack rm vote 

At present, this is still a detached operation that will take time to run in the background.


If for some reason you still want the stack and service definitions, you can scale the "replicated" services down to 0 replicas, and "global" services you can add a constraint that doesn't match any node.

docker service update --replicas 0 $service_name docker service update --constraint-add node.labels.no_such_node=true $service_name 
like image 108
BMitch Avatar answered Sep 18 '22 23:09

BMitch