Typical command:
docker container ls -f 'status=exited'
However, in this list only one of the possible idle statuses will be indicated. Here is a list of all possible statuses:
- created
- restart
- works
- removal
- was silent
- came out
- dead
You can filter multiple statuses by passing multiple status filters:
docker container ls -f 'status=exited' -f 'status=dead' -f 'status=created'
If you integrate this using an automatic cleanup script, you can associate one command with another with some bash syntax, display only the container identifier with -q , and restrict only containers that successfully complete the exit code filter:
docker container rm $(docker container ls -q -f 'status=exited' -f 'exited=0')
For more information on the filters you can use, see the Docker documentation: https://docs.docker.com/engine/reference/commandline/ps/#filtering
BMitch Aug 4 '18 at 17:36 2018-08-04 17:36
source share