Created
May 24, 2015 06:07
-
-
Save en0/392517ca5b798a5d0726 to your computer and use it in GitHub Desktop.
A quick wrapper for running docker containers
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
#!/usr/bin/env bash | |
# Look for existing instances | |
CID=$(docker ps -a -f name=$CNAME -q) | |
if [ ! -z "${CID}" ] | |
then | |
# Determin if the instance is already running | |
IS_RUNNING=$(docker inspect --format='{{.State.Running}}' $CID) | |
if [ "${IS_RUNNING}" == "true" ] | |
then | |
# Already running. | |
echo "Service is already up" | |
else | |
# Not running but exists, Restart it. | |
echo "Starting existing service instance." | |
docker start $CID | |
exit $? | |
fi | |
else | |
# No instance found. Start a new one. | |
start_docker | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment