docker remove all exited containers 1

docker remove all exited containers

sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm

Here is what the above code is Doing:
1. sudo docker ps -a | grep Exit
– This will list all the containers that have exited.
2. cut -d ‘ ‘ -f 1
– This will cut the output of the previous command and return only the first column.
3. xargs sudo docker rm
– This will take the output of the previous command and pass it as an argument to the docker rm command.

Similar Posts