I am trying to stop / prune docker containers according to 2 conditions:
- image name
- time they've been running for
For instance, I could want to stop all containers from image image-name that have been running for over 24h.
By reading the documentation, it seems the --filter option is not consistent at all since docker container prune has the until filter, which is useful to filter containers by age but doesn't have the ancestor filter. This filter is available for docker ps though, and it filters by image name. If I could run docker ps with until, I could just pipe the ids to docker stop but again, the filters are not consistent between commands.
Finally, docker container prune has a label filter but I can't seem to find what a label is in docker or if it could be useful in this case. I tried label=image=<image-name> without success.
Update: I've realized docker container prune does not have a way of removing running containers, only stopped ones, so I'd need to find a way to fitler by age on docker ps