Last active
December 11, 2016 05:37
-
-
Save kazukgw/dd4f14b3a5d599840df95a0373b6e292 to your computer and use it in GitHub Desktop.
run devenv
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
function devenv() { | |
cname=$(docker ps -a --format '{{.Image}} {{.Names}} {{.Status}}' | awk 'match($1, /devenv/) {print $2} ') | |
if [[ -n "$cname" ]]; then | |
status=$(docker ps -a --format '{{.Image}} {{.Names}} {{.Status}}' | awk 'match($1, /devenv/) {print $3} ') | |
echo "==> status: $status" | |
if [[ $status =~ ^Up.* ]]; then | |
echo "==> exec $cname" | |
docker exec -it $cname /bin/bash | |
else | |
echo "==> start and attach $cname" | |
docker attach $(docker start $cname) | |
fi | |
else | |
echo "==> run new devenv container" | |
docker-compose -f $DEVENV_COMPOSE_FILE run --name devenv devenv | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment