-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontainer
executable file
·44 lines (38 loc) · 1017 Bytes
/
container
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
DIR="$(readlink -f $(dirname $0))"
UID_GID=`id -u`:`id -g`
DOCKER_IMG="zultron/freeipa-cloud-prov:latest"
CONTAINER_NAME=freeipa-cloud-prov
EXISTING_CONTAINER=$(docker ps -aq --filter=name=$CONTAINER_NAME)
cd "$DIR"
if tty >/dev/null; then
DOCKER_TTY_ARGS="-t"
fi
if test "$1" = "-b"; then
set -x
exec docker build -t ${DOCKER_IMG} -f dockerfiles/Dockerfile.manager \
dockerfiles
elif test "${1:0:1}" = "-"; then
{
echo "Usage:"
echo " $0 -b # build container"
echo " $0 COMMAND ARG ... # run command with args in container"
} >&2
exit 1
elif test -n "$EXISTING_CONTAINER"; then
set -x
exec docker start -ai $EXISTING_CONTAINER
else
shift
DOCKER_EXTRA_ARGS="$(
test ! -f .docker-extra-args || cat .docker-extra-args)"
set -x
exec docker run -i ${DOCKER_TTY_ARGS} \
--name freeipa-cloud-prov \
-v $HOME:/home/user \
-v $PWD:/data \
-u $UID_GID \
$DOCKER_EXTRA_ARGS \
--entrypoint /bin/bash \
${DOCKER_IMG} "$@"
fi