Last active
September 11, 2015 18:35
-
-
Save AlexZeitler/9c2d0d86a7b902500a74 to your computer and use it in GitHub Desktop.
Docker snippets
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
VBoxManage modifyvm "default" --natpf1 "postgres,tcp,127.0.0.1,5432,,5432" |
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
# 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 |
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
# 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