forked from ArduPilot/redtail
-
Notifications
You must be signed in to change notification settings - Fork 17
/
run_redtail_tf_docker.sh
executable file
·42 lines (36 loc) · 1.41 KB
/
run_redtail_tf_docker.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
#!/bin/bash
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
# Full license terms provided in LICENSE.md file.
REDTAIL_TF_NAME=$1
if [[ -z "${REDTAIL_TF_NAME}" ]]; then
REDTAIL_TF_NAME=nvidia-redtail-tf
fi
HOST_DATA_DIR=$2
if [[ -z "${HOST_DATA_DIR}" ]]; then
HOST_DATA_DIR=/data/
fi
CONTAINER_DATA_DIR=$3
if [[ -z "${CONTAINER_DATA_DIR}" ]]; then
CONTAINER_DATA_DIR=/data/
fi
echo "Container name : ${REDTAIL_TF_NAME}"
echo "Host data dir : ${HOST_DATA_DIR}"
echo "Container data dir: ${CONTAINER_DATA_DIR}"
REDTAIL_ID=`docker ps -aqf "name=^/${REDTAIL_TF_NAME}$"`
if [ -z "${REDTAIL_ID}" ]; then
echo "Creating new redtail container."
xhost +
nvidia-docker run -it --privileged --network=host -v ${HOST_DATA_DIR}:${CONTAINER_DATA_DIR}:rw -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix${DISPLAY} -p 8888:8888 -p 6006:6006 --name=${REDTAIL_TF_NAME} nvidia-redtail-tf:1.5 bash
else
echo "Found redtail container: ${REDTAIL_ID}."
# Check if the container is already running and start if necessary.
if [ -z `docker ps -qf "name=^/${REDTAIL_TF_NAME}$"` ]; then
xhost +local:${REDTAIL_ID}
echo "Starting and attaching to ${REDTAIL_TF_NAME} container..."
docker start ${REDTAIL_ID}
docker attach ${REDTAIL_ID}
else
echo "Found running ${REDTAIL_TF_NAME} container, attaching bash..."
docker exec -it ${REDTAIL_ID} bash
fi
fi