1 00:00:00,667 --> 00:00:03,840 Having unnecessary images lying around our host 2 00:00:03,840 --> 00:00:07,440 can be quite a bother. Firstly, it consumes a lot 3 00:00:07,440 --> 00:00:10,080 of disk space and having multiple version of 4 00:00:10,080 --> 00:00:13,367 similar images can cause confusions nonetheless. 5 00:00:13,867 --> 00:00:16,501 Let's list out our available images. 6 00:00:16,501 --> 00:00:17,834 [No Audio] 7 00:00:17,834 --> 00:00:22,320 Just take a look, the list is already exhaustive. Time to 8 00:00:22,320 --> 00:00:25,134 narrow it down a bit to keep things neat and tidy. 9 00:00:25,634 --> 00:00:29,790 First, let's use rm or remove command. We will 10 00:00:29,790 --> 00:00:33,601 remove an image with 1-alpine perl tag. 11 00:00:33,601 --> 00:00:36,930 As you may remember, these images were pulled as a 12 00:00:36,930 --> 00:00:40,230 stack of layered intermediate images, so they will 13 00:00:40,230 --> 00:00:42,201 also be removed similarly. 14 00:00:43,101 --> 00:00:47,160 All of the intermediate images along with the resultant image will be 15 00:00:47,160 --> 00:00:51,267 removed from our host. Just to verify how did our command do, 16 00:00:51,367 --> 00:00:53,567 let's get another list of images 17 00:00:53,567 --> 00:00:58,401 and we shouldn't find any image with 1-alpine perl tag. 18 00:00:59,434 --> 00:01:02,850 Another way to write image rm, is to 19 00:01:02,850 --> 00:01:06,601 simply write rmi and follow it by image id. 20 00:01:06,601 --> 00:01:10,710 When we use image id instead of image tag, all images 21 00:01:10,710 --> 00:01:13,367 containing that id will be removed. 22 00:01:13,501 --> 00:01:18,960 Here, 1-alpine and alpine variants of nginx image 23 00:01:19,140 --> 00:01:20,767 will be affected by this command. 24 00:01:21,101 --> 00:01:25,467 On the other hand, such an operation involving id of the image 25 00:01:25,467 --> 00:01:29,167 which is used more than once cannot be performed normally. 26 00:01:29,401 --> 00:01:32,190 That's why we are getting this error and 27 00:01:32,190 --> 00:01:36,067 the suggestion to remove them forcefully, let's do so. 28 00:01:36,067 --> 00:01:38,567 We will use the same command with --force tag. 29 00:01:39,234 --> 00:01:42,600 As you may notice, all of the images with this id 30 00:01:42,750 --> 00:01:44,734 will be freed from that tag 31 00:01:44,734 --> 00:01:47,850 and they will be removed along with their intermediate images.