Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit 2e9f20b

Browse files
committed
Improve pass-through of docker arguments
1 parent 4edca2f commit 2e9f20b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

nvidia-docker

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#! /bin/bash
2-
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
# Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
33

44
NV_DOCKER=${NV_DOCKER:-"docker"}
55

6-
DOCKER_ARGS=""
7-
NV_DOCKER_ARGS=""
6+
DOCKER_ARGS=()
7+
NV_DOCKER_ARGS=()
88
while [ $# -gt 0 ]; do
99
arg=$1
1010
shift
11-
DOCKER_ARGS="$DOCKER_ARGS $arg"
11+
DOCKER_ARGS+=("$arg")
1212
case $arg in
1313
run|create)
14-
NV_DOCKER_ARGS="--runtime=nvidia"
15-
if [ ! -z $NV_GPU ]; then
16-
NV_DOCKER_ARGS="$NV_DOCKER_ARGS -e NVIDIA_VISIBLE_DEVICES=${NV_GPU// /,}"
14+
NV_DOCKER_ARGS+=("--runtime=nvidia")
15+
if [ ! -z "${NV_GPU}" ]; then
16+
NV_DOCKER_ARGS+=(-e NVIDIA_VISIBLE_DEVICES="${NV_GPU// /,}")
1717
fi
1818
break
1919
;;
@@ -31,4 +31,4 @@ if [ ! -z $NV_DEBUG ]; then
3131
set -x
3232
fi
3333

34-
$NV_DOCKER $DOCKER_ARGS $NV_DOCKER_ARGS "$@"
34+
exec $NV_DOCKER "${DOCKER_ARGS[@]}" "${NV_DOCKER_ARGS[@]}" "$@"

0 commit comments

Comments
 (0)