Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Prune Old Unused Docker Containers and Images

    Mark ShustMark Shust

    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.

    dockerDocker
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss