Docker

Rocky Warren
Rocky Warren
November 2, 20201 min read

Stop and remove all Docker containers,

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Delete images from a particular repository,

docker images | awk '{print $1":"$2}' | grep local/my-service | xargs -n1 docker rmi

Delete containers using a particular image,

docker ps -a | awk '{print $1,$2}' | grep node:12-alpine | awk '{print $1}' | xargs -I {} docker rm {}