Cool Docker Commands
Basic Commands
1. docker images
Lists images.
2. docker ps
Lists containers.
Remove all images from Containers
docker container rm -f $(docker container ls -aq)
-f
flag forcefully removes containers including the running containers.
-q
flag lists the IDs of the containers
-a
flag includes the IDs of stopped containers also.
We can also combine them like so -aq
.
Remove all images from Docker
You may want to remove containers because you might get an error if some images are being used in containers.
docker image rm $(docker image ls -q)
docker image ls
lists are images
& the -q
flag lists the image IDs only.
Passing that list to the rm
command removes the images.