Created
March 29, 2015 16:48
-
-
Save xav-b/b6a03b63b690934d68f6 to your computer and use it in GitHub Desktop.
Run a convenient sandbox container
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 | |
DEFAULT_NAME="lab" | |
DEFAULT_IMAGE="ubuntu" | |
WORKDIR="/root/app" | |
REPL="bash" | |
usage() { | |
printf "hack --help\t\tprint help\n" | |
printf "hack <image> <name>\trun a lab container\n" | |
} | |
hack() { | |
local image=${1:-${DEFAULT_IMAGE}} | |
local name=${2:-${DEFAULT_NAME}} | |
docker run \ | |
-it --name ${name} \ | |
--volume $PWD:${WORKDIR} --workdir ${WORKDIR} \ | |
${image} ${REPL} | |
} | |
if [ "$1" == "--help" ]; then | |
usage | |
exit 0 | |
fi | |
hack $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment