Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions python3/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env bash
DEFAULT_UID=10000
DEFAULT_GID=10000

set -e

if [[ -v DEBUG ]]
Expand Down Expand Up @@ -85,8 +82,15 @@ then
fi

# set up privilege dropping to user and group
PRIVDROP=$(create_user_and_group "${RUNAS_UID:-$DEFAULT_UID}" "${RUNAS_GID:-$DEFAULT_GID}")
echo "Dropping privileges to $($PRIVDROP id -u):$($PRIVDROP id -g)"
PRIVDROP=
if [ -n "$RUNAS_UID" ] || [ -n "$RUNAS_GID" ]
then
PRIVDROP=$(create_user_and_group "${RUNAS_UID}" "${RUNAS_GID}")
echo "Dropping privileges to $($PRIVDROP id -u):$($PRIVDROP id -g)"
else
echo "ERROR: Please set RUNAS_UID and RUNAS_GID environment variables"
exit 1
fi

# run custom scripts before dropping privileges
echo "Running custom scripts in /container-init as root"
Expand Down
12 changes: 6 additions & 6 deletions python3/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ echo "Remove old container"
docker rm python3

# With RUNAS_UID and RUNAS_GID
echo
echo "Run image with env"
docker run --name python3 --env RUNAS_UID=10001 --env RUNAS_GID=10001 python3:test
# echo
# echo "Run image with env"
# docker run --name python3 --env RUNAS_UID=10000 --env RUNAS_GID=10000 python3:test

# Without RUNAS_UID and RUNAS_GID
# echo
# echo "Run without env"
# docker run --name python3 python3:mve
echo
echo "Run without env"
docker run --name python3 python3:test

echo
echo "Start container"
Expand Down