Remove docker service and wait for containers to stop

by redgeoff   Last Updated January 11, 2018 19:00 PM

Let's say I have the Docker Swarm services myservice1 and myservice2. How can I remove these services and wait for the associated containers to stop?



Answers 1


To stop and wait for a single service:

$ docker service rm myservice1 && docker wait $(docker ps -f "name=myservice1" -q)

For multiple services:

$ docker service rm myservice1 myservice2 && docker wait $(docker ps -f "name=myservice1" -f "name=myservice2" -q)
redgeoff
redgeoff
January 11, 2018 18:52 PM

Related Questions


docker stack network issue

Updated September 11, 2017 12:00 PM

Browser services' container in Docker Swarm mode

Updated April 26, 2017 08:00 AM



Preventing against a DDoS attack of a load balancer

Updated September 28, 2017 17:00 PM