buy tb500

Archive for the ‘Containers’ Category

Docker deletes all containers that have a status of exited

Monday, November 7th, 2022

docker rm $(docker ps -a -q -f status=exited)

or

docker container prune

the two commands are same, the latest one is the newest one. in the new version of Docker

This command deletes all containers that have a status of exited. In case you’re wondering, the -q flag, only returns the numeric IDs and -f filters output based on conditions provided. One last thing that’ll be useful is the --rm flag that can be passed to docker run which automatically deletes the container once it’s exited from. For one off docker runs, --rm flag is very useful.

Delete all docker containers with existed status

Wednesday, June 1st, 2022

docker rm $(docker ps -a -q -f status=exited)