From f34586f2ad4a591498f629b367c5aa1326c97eb5 Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Mon, 3 Aug 2020 23:29:18 +0100 Subject: [PATCH 01/11] init confs and docs for mac #3, #5 --- docker-cmd-mac.sh | 168 ++++++++++++++++++++++++++++++++ docker-image-mac/.DS_Store | Bin 0 -> 6148 bytes docker-image-mac/Dockerfile | 109 +++++++++++++++++++++ docker-image-mac/tf-gpu-test.py | 3 + docker-image-mac/training.sh | 26 +++++ docs/howto-mac.md | 61 ++++++++++++ 6 files changed, 367 insertions(+) create mode 100755 docker-cmd-mac.sh create mode 100644 docker-image-mac/.DS_Store create mode 100644 docker-image-mac/Dockerfile create mode 100755 docker-image-mac/tf-gpu-test.py create mode 100755 docker-image-mac/training.sh create mode 100644 docs/howto-mac.md diff --git a/docker-cmd-mac.sh b/docker-cmd-mac.sh new file mode 100755 index 0000000..5188778 --- /dev/null +++ b/docker-cmd-mac.sh @@ -0,0 +1,168 @@ +#!/bin/bash + +# Example of docker usage for RLLIB + SUMO Utlis +# +# Author: Lara CODECA +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License 2.0 which is available at +# http://www.eclipse.org/legal/epl-2.0. + +set -e +set -u + +IMAGE_NAME="tf-gpu-sumo-$(date +%Y-%m-%d)" +IMAGE_FOLDER="docker-image-mac" +GPU=true +GPU_OPT="--gpus all" +OPTIRUN=false +OPTIRUN_OPT="" +BUILD=false +CACHE=false +RUN=false +SCREEN=false +EXEC=false +CONTAINER="" +DEVEL_DIR="" +LEARN_DIR="" +COMMAND="" +EXP="" +DETACH=false + +function print_help { + echo "Parameters:" + echo " IMAGE name \"$IMAGE_NAME\" [-n, --image-name]" + echo " IMAGE folder \"$IMAGE_FOLDER\" [-f, --image-folder]" + echo " GPU enabled ($GPU) [--no-gpu]" + echo " OPTIRUN disabled ($OPTIRUN) [--with-optirun]" + echo " BUILD: $BUILD [-b, --build], with CACHE: $CACHE [-c, --cache]" + echo " RUN: $RUN [-r, --run], with SCREEN: $SCREEN [-s, --screen]" + echo " EXEC: $EXEC [-e, --exec], CONTAINER: \"$CONTAINER\" (use docker ps for the id)" + echo " COMMAND: \"$COMMAND\" [--cmd]" + echo " EXP: \"$EXP\" [--exp]" + echo " DETACH: ($DETACH) [--detach]" + echo " DEVELOPMENT dir \"$DEVEL_DIR\" [-d, --devel]" + echo " LEARNING dir \"$LEARN_DIR\" [-l, --learn]" +} + +for arg in "$@" +do + case $arg in ## -l=*|--lib=*) DIR="${i#*=}" is the way to retrieve the parameter + -n=*|--image-name=*) + IMAGE_NAME="${arg#*=}" + ;; + -f=*|--image-folder=*) + IMAGE_FOLDER="${arg#*=}" + ;; + --no-gpu) + GPU=false + GPU_OPT="" + ;; + --with-optirun) + OPTIRUN=true + OPTIRUN_OPT="optirun" + ;; + --detach) + DETACH=true + ;; + -b|--build) + BUILD=true + ;; + -c|--cache) # it does nothing without BUILD=true + CACHE=true + ;; + -r|--run) + RUN=true + ;; + -s|--screen) # it does nothing without RUN=true + SCREEN=true + ;; + -e=*|--exec=*) # it works only with RUN=false + EXEC=true + CONTAINER="${arg#*=}" + ;; + --cmd=*) + COMMAND="${arg#*=}" + ;; + --exp=*) + EXP="${arg#*=}" + ;; + -d=*|--devel=*) + DEVEL_DIR="${arg#*=}" + ;; + -l=*|--learn=*) + LEARN_DIR="${arg#*=}" + ;; + *) + # unknown option + echo "Unknown option \"$arg\"" + print_help + exit + ;; + esac +done + +print_help + +# Tensorflow original image +# docker run -u $(id -u):$(id -g) --gpus all -it --rm tensorflow/tensorflow:latest-gpu-py3 bash + +## Building the docker image +if [[ "$BUILD" = true ]]; then + if [[ "$CACHE" = true ]]; then + echo "Building the docker container using the cache, if present." + $OPTIRUN_OPT docker build \ + --build-arg USER_ID=$(id -u ${USER}) \ + --build-arg GROUP_ID=$(id -g ${USER}) \ + -t "$IMAGE_NAME" "$IMAGE_FOLDER" + else + echo "Building the docker container ignoring the cache, even if present." + $OPTIRUN_OPT docker build \ + --build-arg USER_ID=$(id -u ${USER}) \ + --build-arg GROUP_ID=$(id -g ${USER}) \ + --no-cache -t "$IMAGE_NAME" "$IMAGE_FOLDER" + fi +fi + +if [[ "$RUN" = true ]]; then + # My docker build + MOUNT_DEVEL="" + if [[ $DEVEL_DIR ]]; then + MOUNT_DEVEL="--mount src=$DEVEL_DIR,target=/home/alice/devel,type=bind" + fi + MOUNT_LEARN="" + if [[ $LEARN_DIR ]]; then + MOUNT_LEARN="--mount src=$LEARN_DIR,target=/home/alice/learning,type=bind" + fi + CONT_NAME="" + if [[ $EXP ]]; then + CONT_NAME="--name $EXP" + fi + if [[ "$DETACH" = true ]]; then + DETACH="-d" + else + DETACH="" + fi + CURR_UID=$(id -u) + CURR_GID=$(id -g) + RUN_OPT="-u $CURR_UID:$CURR_GID --net=host --env DISPLAY=$DISPLAY \ + --volume /tmp/.X11-unix:/tmp/.X11-unix \ + --privileged $MOUNT_DEVEL $MOUNT_LEARN \ + --shm-size 256m $GPU_OPT $CONT_NAME \ + -it $DETACH --rm $IMAGE_NAME:latest" + echo "$OPTIRUN_OPT docker run $RUN_OPT $COMMAND" + + ## Running docker + if [[ "$SCREEN" = true ]]; then + echo "Running the docker in a screen session." + screen -d -m \ + $OPTIRUN_OPT docker run $RUN_OPT $COMMAND + else + $OPTIRUN_OPT docker run $RUN_OPT $COMMAND + fi +else + if [[ "$EXEC" = true ]]; then + echo "Attaching to a running docker (see container id using 'docker ps')." + $OPTIRUN_OPT docker exec -it "$CONTAINER" /bin/bash + fi +fi diff --git a/docker-image-mac/.DS_Store b/docker-image-mac/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Mon, 3 Aug 2020 23:30:23 +0100 Subject: [PATCH 02/11] rm .DS_Store --- docker-image-mac/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docker-image-mac/.DS_Store diff --git a/docker-image-mac/.DS_Store b/docker-image-mac/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Mon, 10 Aug 2020 09:31:31 +0100 Subject: [PATCH 03/11] minor correction about image name --- docs/howto-mac.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 28976c4..0a41e8b 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -12,7 +12,7 @@ Basic command to use: ## Step 2: Run a container of the built image -`sudo bash docker-cmd-mac.sh --image-name=tf-gpu-sumo-2020-08-03 --run --no-gpu` +`sudo bash docker-cmd-mac.sh --image-name={your_image_name} --run --no-gpu` This will run `/home/alice/learning/training.sh` inside the docker container, which will then run `/home/alice/libraries/rllibsumoutils/example/ppotrain.py`. From 97d2053f9f26c49be70c077d79589d8548a32f9a Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Mon, 10 Aug 2020 09:44:49 +0100 Subject: [PATCH 04/11] remove optirun --- docker-cmd-mac.sh | 19 ++++++------------- docs/howto-mac.md | 1 - 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docker-cmd-mac.sh b/docker-cmd-mac.sh index 5188778..b4815a5 100755 --- a/docker-cmd-mac.sh +++ b/docker-cmd-mac.sh @@ -15,8 +15,6 @@ IMAGE_NAME="tf-gpu-sumo-$(date +%Y-%m-%d)" IMAGE_FOLDER="docker-image-mac" GPU=true GPU_OPT="--gpus all" -OPTIRUN=false -OPTIRUN_OPT="" BUILD=false CACHE=false RUN=false @@ -34,7 +32,6 @@ function print_help { echo " IMAGE name \"$IMAGE_NAME\" [-n, --image-name]" echo " IMAGE folder \"$IMAGE_FOLDER\" [-f, --image-folder]" echo " GPU enabled ($GPU) [--no-gpu]" - echo " OPTIRUN disabled ($OPTIRUN) [--with-optirun]" echo " BUILD: $BUILD [-b, --build], with CACHE: $CACHE [-c, --cache]" echo " RUN: $RUN [-r, --run], with SCREEN: $SCREEN [-s, --screen]" echo " EXEC: $EXEC [-e, --exec], CONTAINER: \"$CONTAINER\" (use docker ps for the id)" @@ -58,10 +55,6 @@ do GPU=false GPU_OPT="" ;; - --with-optirun) - OPTIRUN=true - OPTIRUN_OPT="optirun" - ;; --detach) DETACH=true ;; @@ -111,13 +104,13 @@ print_help if [[ "$BUILD" = true ]]; then if [[ "$CACHE" = true ]]; then echo "Building the docker container using the cache, if present." - $OPTIRUN_OPT docker build \ + docker build \ --build-arg USER_ID=$(id -u ${USER}) \ --build-arg GROUP_ID=$(id -g ${USER}) \ -t "$IMAGE_NAME" "$IMAGE_FOLDER" else echo "Building the docker container ignoring the cache, even if present." - $OPTIRUN_OPT docker build \ + docker build \ --build-arg USER_ID=$(id -u ${USER}) \ --build-arg GROUP_ID=$(id -g ${USER}) \ --no-cache -t "$IMAGE_NAME" "$IMAGE_FOLDER" @@ -150,19 +143,19 @@ if [[ "$RUN" = true ]]; then --privileged $MOUNT_DEVEL $MOUNT_LEARN \ --shm-size 256m $GPU_OPT $CONT_NAME \ -it $DETACH --rm $IMAGE_NAME:latest" - echo "$OPTIRUN_OPT docker run $RUN_OPT $COMMAND" + echo "docker run $RUN_OPT $COMMAND" ## Running docker if [[ "$SCREEN" = true ]]; then echo "Running the docker in a screen session." screen -d -m \ - $OPTIRUN_OPT docker run $RUN_OPT $COMMAND + docker run $RUN_OPT $COMMAND else - $OPTIRUN_OPT docker run $RUN_OPT $COMMAND + docker run $RUN_OPT $COMMAND fi else if [[ "$EXEC" = true ]]; then echo "Attaching to a running docker (see container id using 'docker ps')." - $OPTIRUN_OPT docker exec -it "$CONTAINER" /bin/bash + docker exec -it "$CONTAINER" /bin/bash fi fi diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 0a41e8b..66e09ce 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -33,7 +33,6 @@ Default parameters: IMAGE name "tf-gpu-sumo-{today}" [-n, --image-name] IMAGE folder "docker-image-mac" [-f, --image-folder] GPU enabled (true) [--no-gpu] - OPTIRUN disabled (false) [--with-optirun] BUILD: false [-b, --build] with CACHE: false [-c, --cache] RUN: false [-r, --run] From ad4dbcad7f44a2c7da93efb0981f04b0fcd7c54d Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Mon, 10 Aug 2020 10:06:39 +0100 Subject: [PATCH 05/11] add warning about using sudo --- docs/howto-mac.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 66e09ce..1d5188e 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -14,6 +14,8 @@ Basic command to use: `sudo bash docker-cmd-mac.sh --image-name={your_image_name} --run --no-gpu` +> :warning: **Using SUDO for docker is not a good practice**: Due to a problem of user privilege between host and container, `sudo` has to be used here to make it work. We will address this security issue soon. + This will run `/home/alice/learning/training.sh` inside the docker container, which will then run `/home/alice/libraries/rllibsumoutils/example/ppotrain.py`. To facilitate your development, you can add options to synchronize the code on your local system with the docker container. The mappings are as follows: From ac6dd1cc15aeda9efce8b7b66457ac93cb8d9ad2 Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Mon, 10 Aug 2020 11:05:12 +0100 Subject: [PATCH 06/11] de-hardcoded uid and gid settings --- docker-cmd-mac.sh | 18 ++++++++++++++---- docker-image-mac/Dockerfile | 4 ++-- docs/howto-mac.md | 5 ++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/docker-cmd-mac.sh b/docker-cmd-mac.sh index b4815a5..9c2087a 100755 --- a/docker-cmd-mac.sh +++ b/docker-cmd-mac.sh @@ -23,6 +23,8 @@ EXEC=false CONTAINER="" DEVEL_DIR="" LEARN_DIR="" +USER_ID="" +GROUP_ID="" COMMAND="" EXP="" DETACH=false @@ -40,6 +42,8 @@ function print_help { echo " DETACH: ($DETACH) [--detach]" echo " DEVELOPMENT dir \"$DEVEL_DIR\" [-d, --devel]" echo " LEARNING dir \"$LEARN_DIR\" [-l, --learn]" + echo " USER ID \"$USER_ID\" [-u, --uid]" + echo " GROUP ID \"$GROUP_ID\" [-g, --gid]" } for arg in "$@" @@ -86,6 +90,12 @@ do -l=*|--learn=*) LEARN_DIR="${arg#*=}" ;; + -u=*|--uid=*) + USER_ID="${arg#*=}" + ;; + -g=*|--gid=*) + GROUP_ID="${arg#*=}" + ;; *) # unknown option echo "Unknown option \"$arg\"" @@ -105,14 +115,14 @@ if [[ "$BUILD" = true ]]; then if [[ "$CACHE" = true ]]; then echo "Building the docker container using the cache, if present." docker build \ - --build-arg USER_ID=$(id -u ${USER}) \ - --build-arg GROUP_ID=$(id -g ${USER}) \ + --build-arg USER_ID="$USER_ID" \ + --build-arg GROUP_ID="$GROUP_ID" \ -t "$IMAGE_NAME" "$IMAGE_FOLDER" else echo "Building the docker container ignoring the cache, even if present." docker build \ - --build-arg USER_ID=$(id -u ${USER}) \ - --build-arg GROUP_ID=$(id -g ${USER}) \ + --build-arg USER_ID="$USER_ID" \ + --build-arg GROUP_ID="$GROUP_ID" \ --no-cache -t "$IMAGE_NAME" "$IMAGE_FOLDER" fi fi diff --git a/docker-image-mac/Dockerfile b/docker-image-mac/Dockerfile index 4e3e2d5..3e9d83a 100644 --- a/docker-image-mac/Dockerfile +++ b/docker-image-mac/Dockerfile @@ -69,8 +69,8 @@ RUN python -m pip install ray[rllib] RUN python -m pip install ray[tune] # Working user -RUN groupadd --gid 222 alice && \ - useradd -m -s /bin/bash -u 502 -g 222 alice && \ +RUN groupadd --gid ${GROUP_ID} alice && \ + useradd -m -s /bin/bash -u ${USER_ID} -g ${GROUP_ID} alice && \ echo "alice:alice" | chpasswd && adduser alice sudo USER alice diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 1d5188e..99be8ac 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -4,11 +4,12 @@ Basic command to use: -`bash docker-cmd-mac.sh --build` +`bash docker-cmd-mac.sh --build --uid=502 --gid=222` - The default tag name of this image is `tf-gpu-sumo-{today_date}`. You can also add option such as `--image-name={new_name}` to specify your own name; - The default path of the dockerfile to be used is `docker-image-mac`. You can adapt to your setting by using option `--image-folder`; - The default image building process does not use cache. You can enable it by adding the option `--cache`. +- The user id and group id are suggested as 502 and 222 respectively. The range of valid values on MacOS needs to be further studied. ## Step 2: Run a container of the built image @@ -46,6 +47,8 @@ Default parameters: DETACH: (true) [--detach] DEVELOPMENT dir "" [-d, --devel] LEARNING dir "" [-l, --learn] + USER_ID "" [-u, --uid] + GROUP_ID "" [-g, --gid] ``` Example of use: From f0d44a0e91bf661a8d8c4fd0ec7a4e6ea476dbe6 Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Tue, 11 Aug 2020 09:50:19 +0100 Subject: [PATCH 07/11] synchronise with the commit 42a5dec --- docker-image-mac/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-image-mac/Dockerfile b/docker-image-mac/Dockerfile index 3e9d83a..f17736a 100644 --- a/docker-image-mac/Dockerfile +++ b/docker-image-mac/Dockerfile @@ -59,10 +59,10 @@ RUN python -m pip install \ rtree \ setproctitle \ shapely \ - tqdm + tqdm # Install Python 3 dependencies for MARL -RUN python -m pip install gym +RUN python -m pip install gym RUN python -m pip install ray RUN python -m pip install ray[debug] RUN python -m pip install ray[rllib] @@ -74,9 +74,9 @@ RUN groupadd --gid ${GROUP_ID} alice && \ echo "alice:alice" | chpasswd && adduser alice sudo USER alice -# Download and install SUMO +# Download and install SUMO Version v1_6_0 WORKDIR /home/alice -RUN git clone --depth 1 https://github.com/eclipse/sumo.git sumo +RUN git clone --depth 1 --branch v1_6_0 https://github.com/eclipse/sumo.git sumo RUN mkdir -p /home/alice/sumo/build/cmake-build-release WORKDIR /home/alice/sumo/build/cmake-build-release RUN cmake -D CHECK_OPTIONAL_LIBS=true -D CMAKE_BUILD_TYPE:STRING=Release /home/alice/sumo From 7d3d34938ac9834901c248367e653a367b3e77d5 Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Tue, 11 Aug 2020 09:53:16 +0100 Subject: [PATCH 08/11] synchronise with the commit fd5ea7a --- docker-cmd-mac.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-cmd-mac.sh b/docker-cmd-mac.sh index 9c2087a..ff2fa1e 100755 --- a/docker-cmd-mac.sh +++ b/docker-cmd-mac.sh @@ -28,6 +28,7 @@ GROUP_ID="" COMMAND="" EXP="" DETACH=false +SHM_SIZE="10g" function print_help { echo "Parameters:" @@ -44,6 +45,7 @@ function print_help { echo " LEARNING dir \"$LEARN_DIR\" [-l, --learn]" echo " USER ID \"$USER_ID\" [-u, --uid]" echo " GROUP ID \"$GROUP_ID\" [-g, --gid]" + echo " SHM_SIZE \"$SHM_SIZE\" [--shm-size]" } for arg in "$@" @@ -96,6 +98,9 @@ do -g=*|--gid=*) GROUP_ID="${arg#*=}" ;; + --shm-size=*) + SHM_SIZE="${arg#*=}" + ;; *) # unknown option echo "Unknown option \"$arg\"" @@ -151,7 +156,7 @@ if [[ "$RUN" = true ]]; then RUN_OPT="-u $CURR_UID:$CURR_GID --net=host --env DISPLAY=$DISPLAY \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ --privileged $MOUNT_DEVEL $MOUNT_LEARN \ - --shm-size 256m $GPU_OPT $CONT_NAME \ + --shm-size $SHM_SIZE $GPU_OPT $CONT_NAME \ -it $DETACH --rm $IMAGE_NAME:latest" echo "docker run $RUN_OPT $COMMAND" From 1301a200792c9d667c307b0a45d21b15313c06ff Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Tue, 11 Aug 2020 10:00:06 +0100 Subject: [PATCH 09/11] add author info --- docs/howto-mac.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 99be8ac..0546f7e 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -1,5 +1,7 @@ # RLLIB SUMO Docker environment for MacOS +### Author: Dr. Shen WANG (shen.wang@ucd.ie) + ## Step 1: Build your docker image Basic command to use: From c5d02771ca073099f34e6b7d3654b3b8035e8a8c Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Tue, 11 Aug 2020 10:02:07 +0100 Subject: [PATCH 10/11] warning info update --- docs/howto-mac.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 0546f7e..54761e7 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -17,7 +17,7 @@ Basic command to use: `sudo bash docker-cmd-mac.sh --image-name={your_image_name} --run --no-gpu` -> :warning: **Using SUDO for docker is not a good practice**: Due to a problem of user privilege between host and container, `sudo` has to be used here to make it work. We will address this security issue soon. +> :warning: **Using SUDO for docker is not a good practice**: Due to a problem of user privilege between host and container, `sudo` has to be used here to make it work. Feel free to let us know if you have any idea to solve this security issue. This will run `/home/alice/learning/training.sh` inside the docker container, which will then run `/home/alice/libraries/rllibsumoutils/example/ppotrain.py`. From 3700450ad87758e25a10864ddf52b2d86cbad11b Mon Sep 17 00:00:00 2001 From: Shen Wang Date: Tue, 11 Aug 2020 11:43:57 +0100 Subject: [PATCH 11/11] update uid gid setting when running docker container --- docker-cmd-mac.sh | 4 ++-- docs/howto-mac.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-cmd-mac.sh b/docker-cmd-mac.sh index ff2fa1e..985b5b5 100755 --- a/docker-cmd-mac.sh +++ b/docker-cmd-mac.sh @@ -151,8 +151,8 @@ if [[ "$RUN" = true ]]; then else DETACH="" fi - CURR_UID=$(id -u) - CURR_GID=$(id -g) + CURR_UID=$USER_ID + CURR_GID=$GROUP_ID RUN_OPT="-u $CURR_UID:$CURR_GID --net=host --env DISPLAY=$DISPLAY \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ --privileged $MOUNT_DEVEL $MOUNT_LEARN \ diff --git a/docs/howto-mac.md b/docs/howto-mac.md index 54761e7..396a58a 100644 --- a/docs/howto-mac.md +++ b/docs/howto-mac.md @@ -15,7 +15,7 @@ Basic command to use: ## Step 2: Run a container of the built image -`sudo bash docker-cmd-mac.sh --image-name={your_image_name} --run --no-gpu` +`sudo bash docker-cmd-mac.sh --image-name={your_image_name} --run --no-gpu --uid=502 --gid=222` > :warning: **Using SUDO for docker is not a good practice**: Due to a problem of user privilege between host and container, `sudo` has to be used here to make it work. Feel free to let us know if you have any idea to solve this security issue.