1 00:00:00,001 --> 00:00:02,167 [No Audio] 2 00:00:02,167 --> 00:00:05,901 So, in this demo, we will learn different ways of 3 00:00:05,901 --> 00:00:09,667 removing the containers. Let's list out all of the 4 00:00:09,667 --> 00:00:14,601 our containers and yes, there are quite a lot of them. 5 00:00:14,601 --> 00:00:18,267 In fact, many of them are not even that 6 00:00:18,267 --> 00:00:21,201 significant at the moment and should be removed. 7 00:00:21,667 --> 00:00:25,301 First, we have the basic rm command, followed by a 8 00:00:25,301 --> 00:00:29,367 containers name. Here, we have preferred a stopped 9 00:00:29,367 --> 00:00:32,101 container cont_from. 10 00:00:32,334 --> 00:00:35,767 Once it is removed, it will disappear from the list. 11 00:00:36,234 --> 00:00:40,201 Then we have the same rm command, but instead of providing 12 00:00:40,201 --> 00:00:43,534 name, we have provided the container ids of the 13 00:00:43,534 --> 00:00:46,901 stopped containers, and the result is the same, 14 00:00:46,901 --> 00:00:50,301 they disappear from the list after being removed. 15 00:00:50,301 --> 00:00:52,701 The case will be a bit different with the running 16 00:00:52,701 --> 00:00:55,534 containers, just to make sure that we are not 17 00:00:55,534 --> 00:00:57,701 making any mistakes while deleting a running 18 00:00:57,701 --> 00:01:01,467 container, it asks us to provide the force 19 00:01:01,467 --> 00:01:05,001 deletion flag. I would say it is a kind gesture, 20 00:01:05,001 --> 00:01:08,401 since it avoids potential unforced errors. 21 00:01:08,401 --> 00:01:11,701 As we add the force flag, nothing can stop us from 22 00:01:11,701 --> 00:01:14,767 removing it. If we want to be kind to containers 23 00:01:14,767 --> 00:01:17,601 and want to kill them properly, we can send the 24 00:01:17,601 --> 00:01:21,801 SIGTERM signal using docker container kill command. 25 00:01:22,134 --> 00:01:25,167 But as you can see, we still have quite a 26 00:01:25,167 --> 00:01:27,601 few containers running and we don't need the 27 00:01:27,601 --> 00:01:29,601 stopped ones for the most part. 28 00:01:29,601 --> 00:01:32,667 To remove the stopped containers we have a command called 29 00:01:32,667 --> 00:01:34,534 docker container prune. 30 00:01:34,767 --> 00:01:36,834 It is a short and sweet command 31 00:01:36,834 --> 00:01:39,834 and doesn't require any names or ids. 32 00:01:39,834 --> 00:01:43,301 It will simply kill all of the dangling containers and 33 00:01:43,301 --> 00:01:45,601 free up whatever resources it can. 34 00:01:46,001 --> 00:01:50,434 We had 3 of such containers which got removed and we got 1.8 35 00:01:50,434 --> 00:01:52,434 megabytes of free space. 36 00:01:52,434 --> 00:01:54,867 Finally, our list of containers 37 00:01:54,867 --> 00:01:57,267 only contain the live ones. 38 00:01:57,267 --> 00:02:01,034 In next module, we'll go deeper into networking