Stop all Containers in Docker

this command lists all containers with it’s numeric IDs:
docker ps -a -q
We add some command line magic, to stop them all:
docker stop $(docker ps -a -q)

Delete all Containers in Docker

After we’ve stopped all the containers, we can delete them. Docker only deletes stopped containers:
docker rm $(docker ps -a -q)

Delete all Images in Docker

docker image rm $(docker images -a -q)