Docker: how to delete all containers or images

How to remove all containers

docker rm $(docker ps -aq)

How to remove all images

docker rmi $(docker images -q)