Skip to content

Instantly share code, notes, and snippets.

@audy
Created February 27, 2019 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save audy/cd7c901cb3d82f6d4d3e8359bf43a8ed to your computer and use it in GitHub Desktop.
Save audy/cd7c901cb3d82f6d4d3e8359bf43a8ed to your computer and use it in GitHub Desktop.
Automatically shut down after all docker containers have exited
#!/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