Created
February 7, 2019 18:07
-
-
Save JPaulMora/8593d735fd8583c0bcbfb21d4dce92f0 to your computer and use it in GitHub Desktop.
Script that logs into new docker shell
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
#!/bin/bash | |
/usr/bin/docker run -ti ubuntu | |
IFS=$'\n' | |
TODAY=$(/bin/date +"%Y-%m-%d") | |
/usr/bin/docker ps -a -f ancestor=ubuntu --format "{{.ID}} {{.CreatedAt}} {{.Status}}" | while read cont | |
do | |
IFS=' ' | |
array=($cont) | |
# if [[ ${array[1]} < $TODAY ]] && /bin/grep -q "Exited" <<<$cont | |
if /bin/grep -q "Exited" <<<$cont | |
then | |
# /bin/echo deleting container ${array[0]} | |
/usr/bin/docker rm ${array[0]} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment