Last active
May 9, 2017 14:48
-
-
Save jeckel/6610fb2211044a4380d80da0ac1993db to your computer and use it in GitHub Desktop.
docker_status.sh
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 | |
function docker_status() { | |
local CONTAINER=$1 | |
local RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2> /dev/null) | |
if [ $? -eq 1 ]; then | |
echo "$CONTAINER does not exist." | |
else | |
if [ "$RUNNING" == "false" ]; then | |
echo "$CONTAINER is not running." | |
else | |
local STARTED=$(docker inspect --format="{{.State.StartedAt}}" $CONTAINER) | |
local NETWORK=$(docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $CONTAINER) | |
echo "$CONTAINER is running. IP: $NETWORK, StartedAt: $STARTED" | |
fi | |
fi | |
} | |
docker_status $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment