Build our own image:
docker build -t my-image .
Delete All Exited Containers (Linux):
docker rm $(docker ps -q -f status=exited)
Delete All Exited Containers (Windows):
docker rm $(docker ps -aqf "status=exited")
On Windows 2016 Server Core: How to restart Docker Service?
Net stop com.docker.service
Net start com.docker.service
List:
$ docker ps -a | grep "pattern"
Remove:
$ docker images | grep "pattern" | awk '{print $1}' | xargs docker rm
Remove images with children (images). We should try to remove unnecessary images before removing the image itself:
docker rmi $(docker images -q -f dangling=true)
docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)
Docker remove TAG images:
1. docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
2. docker images -q -a | xargs docker inspect --format='{{.Id}}{{range $rt := .RepoTags}} {{$rt}} {{end}}'|grep -v ':'
Asmentioned for for docker 1.13+ in Sept. 2016 in "How to remove old and unused Docker images", we can also do the image prune command:
docker image prune