Skip to content

Instantly share code, notes, and snippets.

@basicer
Created August 26, 2015 02:05
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 basicer/85cd2493fbef0191622e to your computer and use it in GitHub Desktop.
Save basicer/85cd2493fbef0191622e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
case "$1" in
enter)
APP="$2"
IMAGE="dokku/$APP"
verify_app_name "$APP"
CONTAINERS=$(find "$DOKKU_ROOT/$APP/" -maxdepth 1 -type f -name "CONTAINER.*")
COUNT=$(echo $CONTAINERS | wc -l)
if [ $COUNT -gt 1 ]; then
echo Found $COUNT containers, not sure which to enter...
echo $CONTAINERS
else
CID=$(cat $CONTAINERS)
shift 2
EXEC_CMD=""
is_image_herokuish_based "$IMAGE" && EXEC_CMD="/exec"
docker exec -t -i $CID $EXEC_CMD ${@:-/bin/bash}
fi
;;
help)
cat
echo " enter <app>, Begin an interactive shell in the running container for <app>"
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment