Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How to Remove All Unused Objects in Docker

    How to Remove All Unused Objects in Docker

    By RahulDecember 5, 20192 Mins ReadUpdated: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.

    Advertisement

    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
    

    Docker
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Error: EACCES: permission denied, scandir (Resolved)

    How To Install Python 3.11 on Ubuntu 22.04 / 20.04

    Excluding URLs from ProxyPass in Apache

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.