简体   繁体   中英

How to delete docker stacks older than x amount

Running a native docker swarm with multiple stacks, there is a need to delete stacks via the managing node with docker stack rm that are older than x amount of time. ie stacks that have been created/ or have been running for more than 5 days for example.

docker stack rm doesn't support the --until filter. How are people dealing with this?

I've experimented with docker stack ls | grep 'my_stack' | awk '{print $1}' docker stack ls | grep 'my_stack' | awk '{print $1}' docker stack ls | grep 'my_stack' | awk '{print $1}' to get the stack name then filtering there on for the 'Current state' column values to create a remove based on time implementation.

docker stack ls | grep 'my_stack' | awk '{print $1}'

I expect to be able to achieve something along the lines of:

docker stack rm 'my_stack' where_stack_is_older_than_x_days

There is no option to do that because docker swarm has not been thought in that way. The idea of having an orchestrator is that you can scale services on demand. This means you could have 0 replicas of a service or 100 . Cleaning up a server is usually done manually and if needed it may reflect a really bad design.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM