summaryrefslogtreecommitdiff
path: root/start-container-docker.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-05-02 06:17:17 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-05-02 06:17:17 +0000
commitd980e142525bcd3dc1b19b4cd7421d6c3321e096 (patch)
treefae81966f41e98c91f3da51fffc5e991cf5e97bb /start-container-docker.sh
parent70a58c74e7ffec39d88dbed5f04955ba3211849c (diff)
start-container-docker: Fix problem with cleaning up stale workspaces
... which are created with root:root owner when bind-mount dir doesn't exist on the host. Change-Id: I63a1a1839c83ca98a997ae4c4302a882b82c315e
Diffstat (limited to 'start-container-docker.sh')
-rwxr-xr-xstart-container-docker.sh21
1 files changed, 18 insertions, 3 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh
index 020e3fd8..3edf4df4 100755
--- a/start-container-docker.sh
+++ b/start-container-docker.sh
@@ -177,11 +177,26 @@ esac
pids=$(( $weight * 5000 )) # 5000 processes per executor
cpus=$(( $weight * 1000 )) # 1000 cpu shares per executor
+bind_mounts=(
+ $HOME/snapshots-ref:$HOME/snapshots-ref:ro
+ $HOME/llvm-reference:$HOME/llvm-reference:ro
+ $WORKSPACE:$WORKSPACE
+)
+
+bind_mounts_opt=()
+for bind_mount in "${bind_mounts[@]}"; do
+ # Make sure all bind-mount directories exist.
+ # If a host bind-mount dir doesn't exist, then docker creates it on
+ # the host with root:root owner, which can't be removed by cleanup job.
+ dir="${bind_mount%%:*}"
+ mkdir -p "$dir"
+
+ bind_mounts_opt=("${bind_mounts_opt[@]}" "-v" "$bind_mount")
+done
+
set -x
session_id=$($DOCKER run --name $session_name -dtP \
- -v $HOME/snapshots-ref:$HOME/snapshots-ref:ro \
- -v $HOME/llvm-reference:$HOME/llvm-reference:ro \
- -v $WORKSPACE:$WORKSPACE \
+ "${bind_mounts_opt[@]}" \
${SECURITY} \
--memory=${memory}M \
--pids-limit=${pids} \