How does one remove a Docker image?
The following are some of the ways to remove docker images/containers:
Remove single image
docker rmi image_name:version/image-id
Remove all images
docker rmi $(docker images -qf "dangling=true")
Kill containers and remove them:
docker rm $(docker kill $(docker ps -aq))
Note: Replace kill
with stop
for graceful shutdown
Remove all images except "my-image"
Use grep to remove all except my-image
and ubuntu
docker rmi $(docker images | grep -v 'ubuntu\|my-image' | awk {'print $3'})
Or (without awk)
docker rmi $(docker images --quiet | grep -v $(docker images --quiet ubuntu:my-image))
Try docker rmi node
. That should work.
Seeing all created containers is as simple as docker ps -a
.
To remove all existing containers (not images!) run docker rm $(docker ps -aq)
Delete all docker containers
docker rm $(docker ps -a -q)
Delete all docker images
docker rmi $(docker images -q)