-
Notifications
You must be signed in to change notification settings - Fork 4
/
run-docker.sh
executable file
·41 lines (36 loc) · 997 Bytes
/
run-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
# General info about new container / image
# This will create a container where the code will be in ./project subfolder
CONTAINER_NAME=kaust/mtl_low
CONTAINER_SHORTCUT_NAME=mtl_low
SUBDIR_NAME=project
PORT_HOST=8888
TAG=latest
# Specs of the current user. These will be arguments to Dockerfile
WORKDIR=$PWD
THIS_UID=`id -u`
THIS_GID=`id -g`
THIS_USER=$USER
echo "Starting $CONTAINER_NAME:$TAG container..."
echo "User: $THIS_USER, UID: $THIS_UID, GID: $THIS_GID"
# Build a container
docker build \
--build-arg MYUID=$THIS_UID \
--build-arg MYGID=$THIS_GID \
--build-arg MYUSER=$THIS_USER \
-t $CONTAINER_NAME .
# Start container. Note that sudo is not necessary, but
# the user won't have root rights anyway
# --rm \
docker run \
-it \
--rm \
--runtime=nvidia \
--privileged \
-v /dev:/dev \
-p $PORT_HOST:8888 \
--shm-size 4G \
--gpus all \
-v $WORKDIR:/workspace/$SUBDIR_NAME \
--name $CONTAINER_SHORTCUT_NAME \
$CONTAINER_NAME:$TAG