File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2- DEFAULT_UID=10000
3- DEFAULT_GID=10000
4-
52set -e
63
74if [[ -v DEBUG ]]
8582fi
8683
8784# set up privilege dropping to user and group
88- PRIVDROP=$( create_user_and_group " ${RUNAS_UID:- $DEFAULT_UID } " " ${RUNAS_GID:- $DEFAULT_GID } " )
89- echo " Dropping privileges to $( $PRIVDROP id -u) :$( $PRIVDROP id -g) "
85+ PRIVDROP=
86+ if [ -n " $RUNAS_UID " ] || [ -n " $RUNAS_GID " ]
87+ then
88+ PRIVDROP=$( create_user_and_group " ${RUNAS_UID} " " ${RUNAS_GID} " )
89+ echo " Dropping privileges to $( $PRIVDROP id -u) :$( $PRIVDROP id -g) "
90+ else
91+ echo " ERROR: Please set RUNAS_UID and RUNAS_GID environment variables"
92+ exit 1
93+ fi
9094
9195# run custom scripts before dropping privileges
9296echo " Running custom scripts in /container-init as root"
Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ echo "Remove old container"
77docker rm python3
88
99# With RUNAS_UID and RUNAS_GID
10- echo
11- echo " Run image with env"
12- docker run --name python3 --env RUNAS_UID=10001 --env RUNAS_GID=10001 python3:test
10+ # echo
11+ # echo "Run image with env"
12+ # docker run --name python3 --env RUNAS_UID=10000 --env RUNAS_GID=10000 python3:test
1313
1414# Without RUNAS_UID and RUNAS_GID
15- # echo
16- # echo "Run without env"
17- # docker run --name python3 python3:mve
15+ echo
16+ echo " Run without env"
17+ docker run --name python3 python3:test
1818
1919echo
2020echo " Start container"
You can’t perform that action at this time.
0 commit comments