- In the preceding recipe, we removed the tags one by one till all the tags were removed and the image was deleted. Perhaps you could use the -f or --force option of the docker image rm to delete all the tags and images in one stroke.
- Before using the --force option, ensure that the image doesn't have any containers spawned from that image. Otherwise, you will end up having dangling images.
- Though it is not recommended, if for any reason you want to remove all containers and images, then you can use the following commands:
- To stop all containers, use the following command:
$ docker container stop $(docker container ls -q)
- To delete all containers, use the following command:
$ docker container rm $(docker container ls ...