• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Remove All Unused Objects in Docker

Written by Rahul, Updated on December 13, 2019

The docker system prune command is used to remove all unused objects on Docker. This command will remove any stopped container, unused images, and all the unused networks.

You may like:

  • How to Import and Export Docker Containers?
  • How to Create, List and Delte Docker Containers?

Docker Remove Unused Objects

Log in to the Docker host and open the command prompt. Then execute the following command to remove stopped container, dangling images, and all the unused networks.

docker system prune

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N]

The default command will prompt for the confirmation. Press ‘y’ to continue. To ignore the confirmation prompt use the -f or --force flag like below

docker system prune --force

To remove all unused images (not only daggling one) use --all or -a flag with prune command. The docker images consist of multiple layers. The Dangling images are layers that have no relationship to any tagged images.

docker system prune --all

By default, the docker system prune command doesn’t remove unused volumes to prevent accidental data loss. But you can use the --volumes flag to prune volumes as well:

docker system prune --volumes

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy