33 lines
534 B
Plaintext
33 lines
534 B
Plaintext
|
#! /bin/sh
|
||
|
|
||
|
self=`basename $0`
|
||
|
|
||
|
ARGS="$*"
|
||
|
unset RUN CONTAINER
|
||
|
|
||
|
set_container_name () {
|
||
|
CONTAINER=`docker ps -l | awk 'NR > 1 {print $NF;exit}'`
|
||
|
[ -n "$CONTAINER" ] || {
|
||
|
echo "*** $self: no container avilable (maybe try later)" >&2
|
||
|
exit 1
|
||
|
}
|
||
|
}
|
||
|
|
||
|
case "$ARGS" in
|
||
|
-*) echo "Usage: $self [/shell|image_name ..]" >&2
|
||
|
exit 2
|
||
|
;;
|
||
|
'') set_container_name
|
||
|
ARGS="$CONTAINER"
|
||
|
RUN=/bin/bash
|
||
|
;;
|
||
|
/*) set_container_name
|
||
|
ARGS="$CONTAINER"
|
||
|
RUN="$*"
|
||
|
esac
|
||
|
|
||
|
set -x
|
||
|
exec docker container exec -it $ARGS $RUN
|
||
|
|
||
|
# End
|