How to remove old and unused Docker images

前端 未结 26 1347
北恋
北恋 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:28

    To prune all images and volumes as well
    docker system prune -af --volumes

    0 讨论(0)
  • 2020-11-22 12:29

    The other answers are great, specifically:

    docker system prune # doesn't clean out old images
    docker system prune --all # cleans out too much
    

    But I needed something in the middle of the two commands so the filter option was what I needed:

    docker image prune --all --filter "until=4320h" # delete images older than 6 months ago; 4320h = 24 hour/day * 30 days/month * 6 months
    

    Hope that helps :)

    For reference: https://docs.docker.com/config/pruning/#prune-images

    0 讨论(0)
提交回复
热议问题