-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker_run.sh
More file actions
executable file
·50 lines (44 loc) · 1.68 KB
/
docker_run.sh
File metadata and controls
executable file
·50 lines (44 loc) · 1.68 KB
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
#!/bin/bash
# Copyright 2025 Keen Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# To run:
# chmod +x docker_run.sh
#
# Both the code folder and image_name are optional, if not provided the code folder will default to the current directory.
#./docker_run.sh /path/to/code
#./docker_run.sh /path/to/code custom_image_name
#
# Inside the container, /path/to/code will be mounted as /workspaces/code
DEFAULT_IMAGE_NAME="keen_physical_gpu"
CODE_FOLDER_PATH=${1:-$(pwd)}
DOCKER_IMAGE_NAME=${2:-$DEFAULT_IMAGE_NAME}
# Get the last directory in the path for the mount point (basename of the code folder)
MOUNT_POINT="/workspaces/$(basename "$CODE_FOLDER_PATH")"
# Run the docker container with the specified image name and mount the code folder to the container
docker run --rm -it \
-v "$CODE_FOLDER_PATH:$MOUNT_POINT" \
-w "$MOUNT_POINT" \
--mount source=/dev,target=/dev,type=bind \
-e DISPLAY=$DISPLAY \
-e XAUTHORITY=/root/.Xauthority \
--gpus=all \
--privileged \
--network=host \
--ipc=host \
--ulimit=memlock=-1 \
--ulimit=stack=67108864 \
--cap-add=SYS_PTRACE \
--volume=/tmp/.X11-unix:/tmp/.X11-unix \
-v ~/.Xauthority:/root/.Xauthority \
"$DOCKER_IMAGE_NAME"