Question-46: How can you delete the Docker Image?

Answer: You can delete the docker image by using command “docker rmi <imageId or image tag>”

Question-47: Why it is mandatory to explicitly delete the image if not needed?

Answer: Please note that unless you explicitly delete an image it will live on your machine forever, even you build a new image with the same name as previous. Because building new image simply moves the tag to the new image and it does not delete or replace the old image.

Question-48: How can you check all the available images on your machine?

Answer: You can use command “docker images”. Which list all the images on your machine and you have to delete the image which you don’t want and save the space on your machine.

Question-49: What is the use of “system prune” command?

Answer: Using “docker system prune” command you can do general cleanup. This will remove all the stopped containers, all untagged images and all unused image layers cached as part of the build process. However, you should use this command very carefully. Because you may not be able to recover the images which are deleted.

Question-50: What is the command to garbage collect Docker Images?

Answer: You can use “docker-gc” tool to garbage collect the Docker image. Usually, professionals schedule this tool using cron to regularly cleanup or garbage collect images which are not in use.