Add script to start docker container
This commit is contained in:
1 parent
713cdf165e
commit
4744ddc633
3 files changed
+57
No files matched your search
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
echo $2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
declare image_name="$1"
|
||||
if [ $# -eq 0 ]; then
|
||||
declare image_name_cmd="$(realpath $(dirname "$0"))/docker_image_name.fish"
|
||||
image_name="$(eval $image_name_cmd)"
|
||||
fi
|
||||
echo "${USER}s_$image_name"
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "spark-crypto_18.04"
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare image_name="$1"
|
||||
declare cont_name="$2"
|
||||
declare this_dir="$(realpath $(dirname "$0"))"
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
declare image_name_cmd="$this_dir/docker_image_name.sh"
|
||||
image_name="$(eval $image_name_cmd)"
|
||||
fi
|
||||
declare cont_name_cmd="$this_dir/docker_container_name.sh"
|
||||
cont_name="$(eval $cont_name_cmd $image_name)"
|
||||
fi
|
||||
|
||||
# The root repo path (`repo_path`) is mounted to `repo_path_out`. The latter is
|
||||
# stored in a separate variable for convenience.
|
||||
declare repo_path="$(cd .. && git rev-parse --show-toplevel && cd $this_dir)"
|
||||
declare repo_path_out=$repo_path
|
||||
# `working_dir` is the starting dir for all docker shells launched via
|
||||
# `docker exec -it <container> bash`.
|
||||
declare working_dir=$repo_path_out
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
--net host \
|
||||
-h $(hostname) \
|
||||
-e "TZ=America/New_York" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--security-opt seccomp=unconfined \
|
||||
--name $cont_name \
|
||||
-v $repo_path:$repo_path_out \
|
||||
-u $(id -u $USER) \
|
||||
-w $working_dir \
|
||||
--shm-size=4024m \
|
||||
-t \
|
||||
-i \
|
||||
-d \
|
||||
-e DISPLAY="$DISPLAY" \
|
||||
"$image_name" \
|
||||
bash
|
||||
Reference in new issue
Block a user