Prune Old Unused Docker Containers and Images

Mark Shust
InstructorMark Shust
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 2 years ago

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.

[00:00] 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.

[00:08] 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.

[00:28] 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.

[00:44] Use docker system prune -a to remove not only all dangled images, but all unused images as well.

egghead
egghead
~ 48 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today