问题
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