This is an extension of the cool solution I posted earlier.
Let us go through some more docker commands.
Use this command to delete a stopped container.
Example: docker rm 460b4bacfb94
In the above command "460b4bacfb94" is the container ID. You need to run the "docker ps" command to see the container ID.
-a, show all
-q, show only numeric IDs
We can use the above flags with both containers and images.
Use this command to stop all the containers.
Use this command to remove all the containers.
docker rm `docker ps --all`
Use this command to remove all containers in any state.
Use this command to delete an image from local storage.
Use this command to remove all docker images.
Use this command to purge the volume used by dockers.
Note: The volumes exist independently from containers so when a container is removed, a volume is not automatically removed at the same time.
Please be careful with the below command
Use this command to purge all unused images, containers, volumes, and networks.