From aeddfd41d6bd4d44577689eaef6756f2a28ce605 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Wed, 6 Nov 2019 13:50:48 +0100 Subject: [PATCH 1/2] Resolve shellcheck warnings in container-script This fixes a couple of small potential issues pointed out by shellcheck. Signed-off-by: Anton Lundin --- script/run/run.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script/run/run.sh b/script/run/run.sh index f3456720f..dc28eeb7e 100755 --- a/script/run/run.sh +++ b/script/run/run.sh @@ -36,7 +36,7 @@ if [ "$(pwd)" != '/' ]; then fi if [ -n "$COMPOSE_FILE" ]; then COMPOSE_OPTIONS="$COMPOSE_OPTIONS -e COMPOSE_FILE=$COMPOSE_FILE" - compose_dir=$(realpath $(dirname $COMPOSE_FILE)) + compose_dir=$(realpath "$(dirname "$COMPOSE_FILE")") fi # TODO: also check --file argument if [ -n "$compose_dir" ]; then @@ -47,7 +47,7 @@ if [ -n "$HOME" ]; then fi # Only allocate tty if we detect one -if [ -t 0 -a -t 1 ]; then +if [ -t 0 ] && [ -t 1 ]; then DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -t" fi @@ -56,8 +56,9 @@ DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i" # Handle userns security -if [ ! -z "$(docker info 2>/dev/null | grep userns)" ]; then +if docker info 2>/dev/null | grep -q userns; then DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --userns=host" fi +# shellcheck disable=SC2086 exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@" From c8cfc590cc8252a3130c40f5257c32c9a3cd7a82 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Fri, 22 Nov 2019 16:24:09 +0100 Subject: [PATCH 2/2] Better userns detection in container-script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses formatting to have docker info just emit the information we're interested in. Based-on-code-by: Sebastiaan van Stijn Signed-off-by: Anton Lundin Co-Authored-By: Sebastiaan van Stijn --- script/run/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/run/run.sh b/script/run/run.sh index dc28eeb7e..5bed51cac 100755 --- a/script/run/run.sh +++ b/script/run/run.sh @@ -56,7 +56,7 @@ DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i" # Handle userns security -if docker info 2>/dev/null | grep -q userns; then +if docker info --format '{{json .SecurityOptions}}' 2>/dev/null | grep -q 'name=userns'; then DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS --userns=host" fi