Created
July 18, 2022 06:43
-
-
Save lopesivan/39d40bb58aff5e132f9026a59287db1d to your computer and use it in GitHub Desktop.
Docker no-root engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$GID" -o -z "$UID" -o -z "$USER" -o -z "$GROUP" ]; then | |
echo Running as root | |
exec "$@" | |
else | |
if [ ! $(getent group $GROUP) -a ! $(getent group $GID) ]; then | |
echo Creating group $GROUP with id $GID | |
groupadd -g $GID $GROUP | |
else | |
echo Group name $GROUP or id $GID already exist | |
fi | |
if [ ! $(getent passwd $USER) -a ! $(getent passwd $UID) ]; then | |
echo Creating user $USER with id $UID | |
useradd -u $UID -g $GID $USER | |
else | |
echo User name $USER or id $UID already exist | |
fi | |
export HOME=/home/$USER | |
chown $USER:$GROUP -R /opt/android-sdk-linux | |
mkdir -p $HOME | |
chown $USER:$GROUP $HOME | |
exec /opt/bin/su-exec $USER "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment