File tree 4 files changed +112
-1
lines changed
4 files changed +112
-1
lines changed Original file line number Diff line number Diff line change @@ -114,3 +114,35 @@ An example cni file is:
114
114
}
115
115
}
116
116
```
117
+
118
+
119
+
120
+ Container Filesystem Binds
121
+ --------------------------
122
+
123
+ Currently runX only supports filesystem binds. The defaults are bind and RW.
124
+ You can also pass any -o arguement mount uses. Now you use them in containerd
125
+ like:
126
+
127
+ ```
128
+ ctr ... --mount type=bind,src=/tmp,dst=/host,options=bind:rw ...
129
+ ```
130
+
131
+ which is the same as:
132
+
133
+ ```
134
+ ctr ... --mount type=bind,src=/tmp,dst=/host ...
135
+ ```
136
+
137
+ Or to have it RO and disable execution:
138
+
139
+ ```
140
+ ctr ... --mount type=bind,src=/tmp,dst=/host,options=ro:noexec ...
141
+ ```
142
+
143
+ Likewise to just use rbind rather than bind:
144
+
145
+
146
+ ```
147
+ ctr ... --mount type=bind,src=/tmp,dst=/host,options=rbind ...
148
+ ```
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ set -o pipefail
18
18
# Path to statically built busybox binary i.e.
19
19
# busybox=/usr/bin/busybox-static-aarch64
20
20
21
- execs=" start delete state serial_start create pause"
21
+ execs=" start delete state serial_start create pause mount "
22
22
23
23
# Clean the repo, but save the vendor area
24
24
if [ " x${1:- } " != " x" ] && [ " clean" == " $1 " ]; then
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ workpath=/usr/share/runX
4
+ MNT_MAX_IT=30
5
+ OPT_MAX_IT=15
6
+ UMNT_MAX_IT=5
7
+
8
+ containerid=" $1 "
9
+ crundir=" $2 "
10
+ op=" $3 "
11
+ bundle=$( cat " $crundir " /bundle )
12
+ configfile=" $bundle " /config.json
13
+ mountpoint=$( cat " $crundir " /rootfs )
14
+
15
+ for (( i= 0 ; i < MNT_MAX_IT ; i++ ))
16
+ do
17
+ jq_type=$( jq -r .[\" mounts\" ][$i ][\" type\" ] " $configfile " )
18
+
19
+ if test " $jq_type " = " null"
20
+ then
21
+ break
22
+ fi
23
+
24
+ if test " $jq_type " = " bind"
25
+ then
26
+ jq_des=$( jq -r .[\" mounts\" ][$i ][\" destination\" ] " $configfile " )
27
+ jq_src=$( jq -r .[\" mounts\" ][$i ][\" source\" ] " $configfile " )
28
+
29
+ if test " $op " = " mount"
30
+ then
31
+ jq_rw=" rw"
32
+ jq_bind=" bind"
33
+ jq_cmd=" "
34
+ for (( j= 0 ; j < OPT_MAX_IT ; j++ ))
35
+ do
36
+ jq_opt=$( jq -r .[\" mounts\" ][$i ][\" options\" ][$j ] " $configfile " )
37
+
38
+ case " $jq_opt " in
39
+ " null" )
40
+ break
41
+ ;;
42
+ " bind" )
43
+ ;&
44
+ " rbind" )
45
+ jq_bind=" $jq_opt "
46
+ ;;
47
+ " rw" )
48
+ ;&
49
+ " ro" )
50
+ jq_rw=" $jq_opt "
51
+ ;;
52
+ * )
53
+ jq_cmd+=" $jq_opt ,"
54
+ ;;
55
+ esac
56
+ done
57
+
58
+ mkdir -p " $mountpoint$jq_des "
59
+ mount -o " $jq_cmd$jq_bind " " $jq_src " " $mountpoint$jq_des "
60
+ if test " $jq_rw " = " ro"
61
+ then
62
+ mount -o " $jq_cmd$jq_bind ,remount,ro" " $mountpoint$jq_des "
63
+ fi
64
+ else
65
+ for (( j= 0 ; j < UMNT_MAX_IT ; j++ ))
66
+ do
67
+ umount " $mountpoint$jq_des "
68
+ if test " $? " = " 0"
69
+ then
70
+ break
71
+ else
72
+ sleep 1
73
+ fi
74
+ done
75
+ fi
76
+ fi
77
+ done
Original file line number Diff line number Diff line change @@ -116,8 +116,10 @@ then
116
116
elif test $cmd = " kill"
117
117
then
118
118
$workpath /delete $containerid
119
+ $workpath /mount $containerid " $crundir " unmount
119
120
elif test $cmd = " create"
120
121
then
122
+ $workpath /mount $containerid " $crundir " mount
121
123
$workpath /create $containerid " $crundir "
122
124
123
125
if test " $guestconsole "
You can’t perform that action at this time.
0 commit comments