1
0
mirror of /repos/baseimage-docker.git synced 2025-12-30 08:01:31 +01:00
baseimage-docker/tools/docker-bash
2014-07-16 21:07:49 +02:00

30 lines
675 B
Bash
Executable File

#!/bin/sh
set -e
SELFDIR=`dirname "$0"`
SELFDIR=`cd "$SELFDIR" && pwd`
usage()
{
echo "Usage: docker-bash <CONTAINER_ID> [COMMAND...]"
echo "Login to a Baseimage-based Docker container using nsenter." \
"If COMMAND is not given, opens an interactive shell." \
"Otherwise, runs COMMAND inside the container."
}
if test $# = 0; then
usage
exit
fi
CONTAINER_ID="$1"
shift
PID=`docker inspect -f "{{ .State.Pid }}" "$CONTAINER_ID"`
if test $# = 0; then
exec "$SELFDIR/baseimage-docker-nsenter" --target "$PID" --mount --uts --ipc --net --pid -- /bin/bash -l
else
exec "$SELFDIR/baseimage-docker-nsenter" --target "$PID" --mount --uts --ipc --net --pid -- "$@"
fi