docker ps -q -a | xargs docker rm
-q prints only the container IDs
-a prints all containers
Notice that it uses xargs to issue a remove container command for each container ID
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
awk must use a single quote (this filters all image IDs)
docker rm $(docker ps -aq -f status=exited)