I want to remove all services I created in a Swarm:
To remove all the containers I used:
docker rm -f $(docker ps -a -q)
Is there a way to remove all the service with one line ?
I don't have a stack:
so docker stack rm STACK_NAME
won't work.
The same solution exists in services:
docker service rm $(docker service ls -q)
You can just remore the stack
docker stack rm nameofstack
With this, all services will be removed.
To clean all volumes, containers, images and networks you can use:
docker system prune -a -f
Found a way:
docker service ls | grep -v '^ID' | awk '{print $1}' | xargs docker service rm
This is a one way to do it.
docker service rm $(docker service ls --format "{{.ID}}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With