1- Delete all containers
docker ps -q -a | xargs docker rm
-q prints only the container IDs -a prints all containers
Use
xargs
to issue a remove container command for each container ID
2- Delete all untagged images
docker rmi -f $(docker images | grep "^<none>" | awk '{print $3}')
Awk must use a single quote otherwise does not recognize the space seperators.