Containerisation

Useful Docker Commands

Kill all running containers:

docker kill $(docker ps -q)

Delete all stopped containers:

docker rm $(docker ps -a -q)

Delete all images:

docker rmi $(docker images -q)

Delete all unused & unnamed images:

docker rmi -f $(docker images -f "dangling=true" -q)

Remove all containers with status=exited:

docker rm $(docker ps -q -f status=exited)

Stop all containers (will run stop only for active):

docker stop $(docker ps -q)

Stop all containers (will run stop only for all):

docker stop $(docker ps -aq)

Remove all dangling images:

docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 2>/dev/null