Skip to content

Commit 020b891

Browse files
committed
feat: add --user parameter to container run.sh script
Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
1 parent 459f180 commit 020b891

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

container/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ INTERACTIVE=
4343
USE_NIXL_GDS=
4444
RUNTIME=nvidia
4545
WORKDIR=/workspace
46+
USER=
4647

4748
get_options() {
4849
while :; do
@@ -124,6 +125,14 @@ get_options() {
124125
missing_requirement "$1"
125126
fi
126127
;;
128+
--user)
129+
if [ "$2" ]; then
130+
USER="$2"
131+
shift
132+
else
133+
missing_requirement "$1"
134+
fi
135+
;;
127136
--privileged)
128137
if [ "$2" ]; then
129138
PRIVILEGED=$2
@@ -274,6 +283,12 @@ get_options() {
274283
RM_STRING=" --rm "
275284
fi
276285

286+
if [[ ${USER} == "" ]]; then
287+
USER_STRING=""
288+
else
289+
USER_STRING="--user ${USER}"
290+
fi
291+
277292
if [ -n "$USE_NIXL_GDS" ]; then
278293
VOLUME_MOUNTS+=" -v /run/udev:/run/udev:ro "
279294
NIXL_GDS_CAPS="--cap-add=IPC_LOCK"
@@ -310,6 +325,7 @@ show_help() {
310325
echo " [-- stop processing and pass remaining args as command to docker run]"
311326
echo " [--workdir set the working directory inside the container]"
312327
echo " [--runtime add runtime variables]"
328+
echo " [--user override the user for running the container]"
313329
exit 0
314330
}
315331

@@ -347,6 +363,7 @@ ${RUN_PREFIX} docker run \
347363
${NIXL_GDS_CAPS} \
348364
--ipc host \
349365
${PRIVILEGED_STRING} \
366+
${USER_STRING} \
350367
${NAME_STRING} \
351368
${ENTRYPOINT_STRING} \
352369
${IMAGE} \

0 commit comments

Comments
 (0)