-
Notifications
You must be signed in to change notification settings - Fork 0
/
container.sh
executable file
·54 lines (44 loc) · 1.19 KB
/
container.sh
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
#!/bin/bash
# Check if running with root
if [ "$EUID" -ne 0 ];then
sudo -E $0 $@;
exit 1
fi
NAME="pydstream" # image/container name
REPO="nvcr.io/nvidia/deepstream"
TAG="5.0.1-20.09-samples"
ARGS="${*:2}"
# Add l4t if running on Jetson
[ -f "/etc/nv_tegra_release" ] && REPO="$REPO-l4t";
# function to echo and execute commands
function call {
echo ">> $1";$1
}
if [[ $1 == "--build" || $1 == "-b" ]];then
# Build the container
call "docker build -t $NAME --build-arg BASE_IMAGE=$REPO:$TAG . $ARGS"
exit
elif [[ $1 == "--run" || $1 == "-r" ]];then
# Run a new container
xhost +
call "docker run --rm -it --gpus all \
-v $HOME/Videos:/videos \
-v `pwd`:/app \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
--privileged \
--net host \
--name $NAME \
--hostname $NAME \
$NAME ${ARGS:-bash}"
exit
elif [[ $1 == "--attach" || $1 == "-a" ]];then
# Attach to already running container
call "docker exec -it $NAME ${ARGS:-bash}"
exit
elif [[ $1 == "--kill" || $1 == "-k" ]];then
# Kill any other existing container
call "docker kill $NAME"
exit
fi
echo "usage: sudo $0 [--build | --run | --attach | --kill]"