Docker 系列 – docker cheatsheet (持续更新)

#list running containers
docker container

#list all containers
docker container ls -a

#list exit container ids
docker container ls -aq -f status=exited
docker ps -aq -f status=exited

#remove stopped containers
docker ps -aq –no-trunc | xargs docker rm

#list only image ids
docker images -q

#list all images including intermediate images
docker images -a

#prune dangling images
docker rmi $(docker images -f “dangling=true” -q)
docker images -q –filter dangling=true | xargs docker rmi

#remove unused images
docker rmi $(docker images | grep none | awk ‘{ print $3}’)
docker rmi $(docker images –quiet –filter “dangling=true”)
docker images -q –filter dangling=true | xargs docker rmi
docker image prune -f

#remove unused volumes
docker volume rm $(docker volume ls -q )

#remove unused networks
docker network rm $(docker network ls | grep “_default”)

#remove stopped + exited containers
docker rm -v $(docker ps -a | grep “Exit [1-255]” | awk ‘{ print $1 }’)

Docker 系列 – docker cheatsheet (持续更新)