1 - Stop all the containers
docker kill $(docker ps -q)
2 - Run a system prune
This will delete all the images with at least one container
docker system prune -a
if you don't want to delete the images you can delete all the containers with this command
docker rm $(docker ps -a -q)
if you want to delete only the images that has no container asociated just do
docker rmi $(docker images -q)
or
docker system prune