How to use label filter on intermediate containers that get created during build (assuming LABEL is set immediately after FROM command)?

耗尽温柔 提交于 2020-05-17 07:45:09

问题


In the dockerfile, suppose I set a LABEL immediately after the FROM command, then is the label applied to every intermediate container and image generated in the subsequent step?

I know that intermediate containers get removed during build after each step. But I am facing an issue where-in some of the intermediate container are not getting removed. This is causing the images created out of these containers (during the build process) to become dangled.

I can see the images in docker images and containers in docker ps -aq.

I am trying to filter them to get a list - with eventual goal to prune the images. Filter to get list of images based on LABEL: docker images --filter "label=some-key=some-value" - this shows me the images that I wish to prune. But before that I need to stop/prune those containers created from the above images. Filter to get list based on LABEL - docker ps --filter "label=some-key=some-value", but it doesn't return me the container (no value is returned).

When I do docker inspect <container-id>, then I can see label ("some-key"="some-value") in the Config section, under Labels. How can I filter the container based on this label?

来源:https://stackoverflow.com/questions/61794023/how-to-use-label-filter-on-intermediate-containers-that-get-created-during-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!