Skip to content

Instantly share code, notes, and snippets.

@AlexZeitler
Last active September 11, 2015 18:35
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 AlexZeitler/9c2d0d86a7b902500a74 to your computer and use it in GitHub Desktop.
Save AlexZeitler/9c2d0d86a7b902500a74 to your computer and use it in GitHub Desktop.
Docker snippets
VBoxManage modifyvm "default" --natpf1 "postgres,tcp,127.0.0.1,5432,,5432"
# if you're trying to kill a non running container using docker kill,
# it will stop your script execution because it returns exit code 1
function killifrunning {
runs=$(docker inspect -f {{.State.Running}} $1)
if [ $runs == "true" ]; then
docker kill $1
fi
}
killifrunning integration_webui_1
killifrunning integration_customerservice_1
killifrunning integration_db_1
# the short version of killifrunning.sh which shows the error message
# if the container is not running but returns exit code 0 instead of 1
# just try echo $? after executing this line. It should return 0
# without "| true", echo $? would return 1
docker kill integration_webui_1 | true && echo all is fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment