-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib-docker-wrapper.sh
More file actions
51 lines (46 loc) · 1.14 KB
/
Copy pathlib-docker-wrapper.sh
File metadata and controls
51 lines (46 loc) · 1.14 KB
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
45
46
47
48
49
50
51
#!/bin/bash
function run-docker-wrapped-command() {
local REPO='jeroenvm'
local TAG='latest'
local RM='--rm'
local IMAGE=''
local WORK_DIR="$(pwd)"
local MOUNT_DIR="${WORK_DIR}"
declare -a DOCKER_ARGS
DOCKER_ARGS=()
while [ ".$(expr "$1" : '^\(-\).*$')" = '.-' ]
do
OPT="$1"
shift
if [ ".${OPT}" = '.--' ]
then
break
fi
case "${OPT}" in
--keep|-k)
RM=''
;;
--verbose)
set -x
;;
--work-dir|-w)
WORK_DIR="$1" ; shift
MOUNT_DIR="${WORK_DIR}"
;;
--mount-dir|-m)
MOUNT_DIR="$1" ; shift
;;
*)
DOCKER_ARGS[${#DOCKER_ARGS[@]}]="${OPT}"
case "${OPT}" in
-e|-v|--link|--expose|--name|--net|-p)
DOCKER_ARGS[${#DOCKER_ARGS[@]}]="$1"
shift
;;
*)
esac
esac
done
IMAGE="wrapper-$1" ; shift
docker run ${RM} -v "${WORK_DIR}:${WORK_DIR}" -w "${WORK_DIR}" "${DOCKER_ARGS[@]}" "${REPO}/${IMAGE}:${TAG}" "$@"
}