Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
6 views
in DevOps and Agile by (2.3k points)

How can you remove all the containers; stopped/running, both? I think its a lot easier to sometimes just start from scratch. I find it difficult to remove all the containers one by one using the docker rm command as docker won't let me.

1 Answer

0 votes
by (6.9k points)

You can use the below command to stop all containers running: 

$ docker stop $(docker ps -a -q)

then you can remove all of the containers using this command:

$ docker rm $(docker ps -a -q)

If you want to remove all of the containers  without stopping them, you can use th -f flag:

$ docker rm -f $(docker ps -a -q)

Hope this helped :)


Get trained by Docker veterans in online docker training course! 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...