Skip to content

Instantly share code, notes, and snippets.

@hanxue
Created March 11, 2020 01:49
Show Gist options
  • Save hanxue/52393377e24a60bd50d29d916c298e8b to your computer and use it in GitHub Desktop.
Save hanxue/52393377e24a60bd50d29d916c298e8b to your computer and use it in GitHub Desktop.
Docker run options
usage() {
cat >&2 <<EOF
Usage: $0 COMMAND
Commands:
[ cpu | gpu ] [-d] [-X]
EOF
exit 1
}
IMAGE_TYPE="cpu"
IMAGE_NAME=${DOCKER_REPO}$BRAND:${VERSION}-${IMAGE_TYPE}
if [ $# -eq 0 ]; then
usage
fi
command=$1; shift
case "${command}" in
cpu) IMAGE_TYPE="cpu" ;;
gpu) IMAGE_TYPE="gpu" ;;
-h) usage ;;
*) IMAGE_TYPE="cpu" ;;
esac
if [ $? -ne 0 ]; then
usage
fi
eval set -- "${options}"
# -it to run Docker container in interactive mode, -d for detached
DETACHED="-it"
RUN_MODE=""
GUI_ARGS=" -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:$HOME/.Xauthority"
for opt in ${options}; do
case "$opt" in
-d ) DETACHED="-d"; shift 1 ;;
-X ) RUN_MODE=${GUI_ARGS}; shift 1 ;;
esac
done
if [ $# -ne 0 ]; then
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment