-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from cfortier2/fix/docker-cleanup
Convert docker-cleanup to a script for easier maintainability
- Loading branch information
Showing
2 changed files
with
15 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# this exists because trying to escape bash commands in a sytemd unit is super sadtimes | ||
|
||
if [[ $(/usr/bin/docker ps -a | grep Exited | awk '{print $1 "\\t" $7 "\\t" $10}' | grep week | wc -l) -ne 0 ]] | ||
then | ||
echo "Starting docker cleanup with a max of: $MAX_DOCKER" | ||
/usr/bin/docker ps -a | grep Exited | awk '{print $1 "\\t" $7 "\\t" $10}' | grep week | awk '{print $1}' | head -n $MAX_DOCKER | xargs /usr/bin/docker rm -v | ||
/usr/bin/docker images -a | grep none | awk '{print $3}' | xargs /usr/bin/docker rmi | ||
echo "cleanup complete" | ||
else | ||
echo "nothing to cleanup" | ||
fi | ||
sudo free -h |