How to remove old and unused Docker images

前端 未结 26 1405
北恋
北恋 2020-11-22 11:28

When running Docker for a long time, there are a lot of images in system. How can I remove all unused Docker images at once safety to free up the storage?

In additio

26条回答
  •  太阳男子
    2020-11-22 12:07

    Assuming you have Docker 1.13 or higher you can just use the prune commands. For your question specifically for removing old images, you want the first one.

    # Remove unused images
    docker image prune
    
    # Remove stopped containers.
    docker container prune
    
    # Remove unused volumes
    docker volume prune
    
    # Remove unused networks
    docker network prune
    
    # Command to run all prunes:
    docker system prune
    

    I would recommend not getting used to using the docker system prune command. I reckon users will accidentally remove things they don't mean to. Personally, I'm going to mainly be using the docker image prune and docker container prune commands.

提交回复
热议问题