docker remove exited containers

C++
# remove containers created between now upto 4hrs back
docker container prune --filter "until=4h"

# remove images created between now upto 4hrs back
docker image prune --filter "until=4h"docker container prune(docker ps -a |findstr Exited) | foreach-object {docker rm $_.split(" ")[-1]}
Source

Also in C++: