-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpodman.run
executable file
·94 lines (82 loc) · 1.97 KB
/
podman.run
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#title :podman.run
#description :This file builds the correct arguments for the podman run cmd
#author :Austin Owens
#date :9/18/2022
#common_usage :./podman.run -u <usr> -s $(pwd)/workspace -i yocto-img <container_cmd>
#=====================================================================================
function print_usage() {
cat <<EOF
OPTIONS:
podman.run [options] container_cmd
-h: Help
-s <name>: Name of the dir to mount outside (src) the container
-u <name>: A user to use inside the container (should be same as container build arg)
-i <name>: The name of the podman image to run
-n: Do not use interactive input (TTY)
container_cmd: What you want to run inside of the container (e.g. /bin/bash)
EOF
exit 1
}
usr=
src_dir=
img=
tty="t"
while getopts 'hu:s:i:n' opt
do
case $opt in
h)
print_usage
;;
u)
usr="$OPTARG"
;;
s)
src_dir="$OPTARG"
;;
i)
img="$OPTARG"
;;
n)
tty=""
;;
*)
print_usage
;;
esac
done
container_cmd=${@:$OPTIND:1}
if [ -z "${container_cmd}" ]
then
echo "Missing a positional argument. container_cmd must be specified."
exit 1
fi
if [ -z ${usr} ]
then
echo "[ERROR] Required argument for podman image -u"
exit 1
fi
if [ -z ${src_dir} ]
then
echo "[ERROR] Required argument for podman image -s"
exit 1
fi
if [ -z ${img} ]
then
echo "[ERROR] Required argument for podman image -i"
exit 1
fi
set -x
# Need `--security-opt seccomp=unconfined` for building gdk-pixbuf/gtk+3, which
# are dependencies of OpenCV. More information can be found here:
# https://github.com/moby/moby/issues/43595
podman run \
-i"${tty}" \
-p 8000:8000 \
--rm \
--name "yocto_build" \
--security-opt seccomp=unconfined \
--userns=keep-id \
--volume="${src_dir}:/home/${usr}/workspace":Z \
-u ${usr} \
-w /home/${usr} ${img} ${container_cmd}