docker ps -aq -f status=exited
docker ps -aq --no-trunc | xargs docker rm
This command will not remove running containers, only an error message will be printed out for each of them.
docker images -q --filter dangling=true | xargs docker rmi
docker ps --since a1bz3768ez7g -q | xargs docker rm
docker ps --before a1bz3768ez7g -q | xargs docker rm
Use --rm for docker build
Use --rm together with docker build to remove intermediary images during the build process.