Skip to content

Instantly share code, notes, and snippets.

@dimaspivak
Created June 2, 2016 01:54
Show Gist options
  • Save dimaspivak/aef815fb634ae313715e5022b6daf4f4 to your computer and use it in GitHub Desktop.
Save dimaspivak/aef815fb634ae313715e5022b6daf4f4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This helper script is designed to be sourced, at which time its functions are made available
# to the user. Most functions defined have functionality defined by environmental variables, which
# can be set during invocation. For example,
#
# PULL=false clusterdock_run ./bin/...
clusterdock_run() {
# Variables:
# - CLUSTERDOCK_TARGET_DIR: a folder on the host to mount into /root/target in the clusterdock
# container
# - PULL: whether to pull the clusterdock image (either true or false; defaults to true)
CLUSTERDOCK_IMAGE="dimaspivak/hbase:clusterdock"
if [ "${PULL}" != "false" ]; then
sudo docker pull "${CLUSTERDOCK_IMAGE}"
fi
if [ -n "${CLUSTERDOCK_TARGET_DIR}" ]; then
TARGET_DIR_MOUNT="-v ${CLUSTERDOCK_TARGET_DIR}:/root/target"
fi
# The /etc/hosts bind-mount allows clusterdock to update /etc/hosts on the host machine for
# better access to internal container addresses.
sudo docker run --net=host \
--privileged \
${TARGET_DIR_MOUNT} \
-v /tmp/clusterdock \
-v /etc/hosts:/etc/hosts \
-v /etc/localtime:/etc/localtime \
-v /var/run/docker.sock:/var/run/docker.sock \
"${CLUSTERDOCK_IMAGE}" $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment