Delete all containers
docker rm $(docker container ls -a -q)
Delete all unnamed images
docker rmi $(docker image ls | grep "<none>" | tr -s ' ' | cut -d ' ' -f 3)
docker image ls lists all images,
grep "<none>" selects all that have the tag (or repository! or part of name!) “<none>” ,
tr -s ' ' merges sequences of spaces to a single space,
cut -d ' ' -f 3 splits each line at the space and gives the third column (the image id).
The list of ids is then passed on to
docker rmi to be deleted.
Use at your own risk!