2021-02-24 16:19:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Run the container
|
2021-05-06 20:32:48 +00:00
|
|
|
# $0 [docker arguments] [-- command and arguments]
|
2021-02-24 16:19:24 +00:00
|
|
|
|
|
|
|
prefix=kdave
|
|
|
|
image=$(basename `pwd` | tr '[A-Z]' '[a-z]')
|
|
|
|
|
|
|
|
declare -a ARGS
|
2021-05-06 20:32:48 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2021-02-24 16:19:24 +00:00
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
2021-05-06 20:32:48 +00:00
|
|
|
*) ARGS+=("$1"); shift;;
|
2021-02-24 16:19:24 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "ARGS: ${ARGS[@]}"
|
|
|
|
echo "RUN : $@"
|
|
|
|
|
2023-04-12 16:43:15 +00:00
|
|
|
# Running inside non-interactive terminal would fail
|
|
|
|
tty=
|
|
|
|
if [ -t 1 ]; then
|
|
|
|
tty=-it
|
|
|
|
fi
|
|
|
|
|
2021-02-24 16:19:24 +00:00
|
|
|
# Device mapper devices are not visible inside the environment if the /dev mount
|
|
|
|
# is the default one (tmpfs instead of devtmpfs)
|
|
|
|
# Mounts and loop device manipulation is required
|
2023-04-12 16:43:15 +00:00
|
|
|
docker run --mount type=bind,source=/dev,target=/dev $tty --privileged "${ARGS[@]}" "$prefix/$image" "$@"
|