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)
January 11, 2018 18:52 PM

Related Questions

Docker Issue - exit status 34

Updated January 25, 2018 13:00 PM

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