How can I delete Docker images by tag, preferably with wildcarding?

前端 未结 2 1622
北海茫月
北海茫月 2020-12-23 00:26

I have some automated processes that spew a bunch of Docker images tagged with meaningful labels. The labels follow a structured pattern.

Is there a way to find and

相关标签:
2条回答
  • 2020-12-23 01:21

    Fun with bash:

    docker rmi $(docker images | grep stuff_ | tr -s ' ' | cut -d ' ' -f 3)
    
    0 讨论(0)
  • 2020-12-23 01:24

    Using only docker filtering:

     docker rmi $(docker images --filter=reference="*:stuff_*" -q)
    
    • reference="*:stuff_*" filter allows you to filter images using a wildcard;
    • -q option is for displaying only image IDs.
    0 讨论(0)
提交回复
热议问题