From the course: Learning Docker

Help! I can't seem to create more containers - Docker Tutorial

From the course: Learning Docker

Help! I can't seem to create more containers

- [Instructor] So you're humming along using Docker for all the things, you've been building and running all of your apps on Docker for months. Then one day you're trying to build a Java app with the open JDK 19 image on Docker hub and see something like this. After reading the tutorial on how to check disc space, you run DF dash H to see where you ran out of space, and you have plenty of space everywhere? What in the world? I don't have space? Where don't I have space? I can't create containers, help! This happens to everyone eventually. Fortunately, this is an easy fix. As we learned from earlier, Docker images are compressed layers of other images. These compressed files need to live somewhere. We also learned that on the Mac, and on some Windows installations, the actual Docker engine runs inside of a tiny virtual machine. What actually happened here is that a folder within that virtual machine ran out of space. So before we start hacking on our system to get at that VM, there are a number of things we can do to fix this. Let's clear my screen before we move on. First, you might have a bunch of images you aren't using anymore, taking up space. We can use "Docker images" to list them. We can also use the "Docker RMI" command to remove images that we are no longer using. The nice thing about this command is that it can take multiple images at a time. Let's say I don't need any of the selenium images, or this engine X image, or this weird XQ image that I created, anymore. I can easily remove them in one fell swoop by typing "Docker RMI", and then the tag for each image I want to delete. So in this case, it'll be "Carlos Nunez XQ, engine X," and both of the selenium images. So "standalone Chrome" and "standalone Firefox". As we can see, they are easily deleted. Remember that you might need to stop containers using some of these images with Docker RM before running this command. You can also add "dash F" to the RMI command to forcefully delete those images, but be wary of data loss here. Docker has another trick up its sleeve to reclaim space. I'm going to press Control K to get rid of that command, and then control L to clear my screen. We can run another command called "Docker system prune". This command smartly removes useless data that's burning a hole in our disc. Now we get a warning here. This warning is usually innocuous. It just tells us that it's going to remove stopped containers that we aren't using anymore, as well as some intermediate layers that were created that are no longer associated with images that are on our machine. Because I know this is safe, I'm going to press the lowercase y, to tell Docker to do this. Now, if you have hesitations about doing this based on this message, you can always press uppercase N to abort it. Like I said, I'm going to press lowercase y. In this case, I've reclaimed all the space that I possibly could, so I don't have any space to reclaim here. But in my experience running this command, a lot of times you can reclaim serious amounts of space. I've reclaimed gigabytes of space doing this. I love this command. It is a very helpful command to have in your toolbox. So now that we've run Docker RMI to remove images and Docker system prune to remove some staleness in our Docker engine, let's try running that Docker run command from earlier. So I'm going to press Ctrl L to clear my screen, then press Ctrl R to look for the Docker run command I ran earlier. I'm just going to type "run" since I don't want to type the whole thing. This is not the command that I want. So I'm going to press control R again until I find it. Here it is. So now I'm going to press enter to continue. And success! We're officially Docker engineers, you all.

Contents