If you use docker as a development environment, you are bound to run into creating a bunch of containers that you don't want anymore. Luckily, there is relatively simple way to get rid of them

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

This will clear all containers that have exited. Here is a more complicated and yet more flexible example taken from stack overflow

$ docker ps --filter "status=exited" | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm

If you really want to clean things up, you can try docker system prune or docker container prune