Created
February 27, 2019 06:33
-
-
Save audy/cd7c901cb3d82f6d4d3e8359bf43a8ed to your computer and use it in GitHub Desktop.
Automatically shut down after all docker containers have exited
This file contains hidden or 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
#!/bin/bash | |
set -euo pipefail | |
container_substring="something-greppable-in-the-name" | |
function check { | |
docker ps | grep -v CONTAINER | grep -v ${container_substring} | |
} | |
until check; do | |
echo "$(date) - checking" | |
sleep 60 | |
done | |
docker ps -a | |
echo "$(date) shutting down!" | |
sudo shutdown now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment