Skip to content

Commit

Permalink
add auto-remove container and network by crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
b2r66sun authored and duskmoon314 committed Apr 28, 2021
1 parent 41bb4c7 commit 484aa68
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/auto_remove_container_network
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/15 * * * * docker ps --format='{{.ID}}' | xargs -n 1 -r docker inspect -f '{{.ID}} {{.State.Running}} {{.State.StartedAt}}' | awk '$2 == "true" && $3 <= "'$(date -d 'now - 15 minutes' -Ins --utc | sed 's/+0000/Z/')'" { print $1 }' | xargs -r docker kill
*/20 * * * * docker network prune -f --filter "until=15m"

0 comments on commit 484aa68

Please sign in to comment.