Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 984 of the free egghead.io lessons, plus get Docker content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

Prune Old Unused Docker Containers and Images

0:52 Docker lesson by

In this lesson, we will look at docker container prune to remove old docker containers. We can also use docker system prune to clean up any containers, images, volumes, and networks all in one command.


egghead.io comment guidelines

Avatar
egghead.io

In this lesson, we will look at docker container prune to remove old docker containers. We can also use docker system prune to clean up any containers, images, volumes, and networks all in one command.

We currently have two running containers and two containers that aren't running. Let's go ahead and prune them out with docker container prune.

This will remove all containers that are not currently running. We also have images on our local machine that may or may not be currently used. There's a similar command named docker image prune, which we can use to prune out all images without attached containers. There are also related commands for volumes and networks.

Let's try another command, docker system prune. This will clear our system of all containers, images, volumes and networks that are not currently being used. Note that it only removes dangled images, or images that don't currently have a relationship to other tagged images.

Use docker system prune -a to remove not only all dangled images, but all unused images as well.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?