简体   繁体   中英

How to remove all services in Docker Swarm

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.

服务中存在相同的解决方案:

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

This is a one way to do it. docker service rm $(docker service ls --format "{{.ID}}")

找到方法:

docker service ls | grep -v '^ID' | awk '{print $1}' | xargs docker service rm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM