4 # Get a login for a docker container.
14 dssh: log in to a docker node
16 usage: dssh: [options]
19 -h: show this help message.
20 -i [ID]: ssh into a docker node with this container ID
21 -n [name]: ssh into a docker node with this name
27 while getopts "hi:n:" flag; do
30 i) DOCKER_IMAGE_ID=${OPTARG};;
31 n) DOCKER_IMAGE_NAME=${OPTARG};;
32 *) echo "getopts error"
39 which docker &>/dev/null || die "docker must be on the PATH."
41 if [ "x${DOCKER_IMAGE_NAME}" == "x" ]; then
42 if [ "x${DOCKER_IMAGE_ID}" == "x" ]; then
47 if [ "x${DOCKER_IMAGE_ID}" == "x" ]; then
50 echo "You must not supply both an ID and a name."
53 DOCKER_IMAGE_ID=$(docker ps -f name=${DOCKER_IMAGE_NAME} -q)
54 [ "x${DOCKER_IMAGE_ID}" == "x" ] && \
55 die "failed to find a docker image named ${DOCKER_IMAGE_NAME}"
58 docker exec -it "${DOCKER_IMAGE_ID}" /bin/bash