runas
The snippet can be accessed without any authentication.
Authored by
nimrod
Docker entrypoint script to run with the correct user. See https://www.shore.co.il/blog/docker_uid/ .
runas 358 B
#!/bin/sh
set -eu
[ "$(id -u)" = "0" ] || { echo "Not running as root, continuing as the current user."; eval exec "$@"; }
command -v stat > /dev/null || { echo "Can't find stat, exiting."; exit 1; }
command -v gosu > /dev/null || { echo "Can't find gosu, exiting."; exit 1; }
uid="$(stat . -c '%u')"
gid="$(stat . -c '%g')"
eval exec gosu "$uid:$gid" "$@"
Please register or sign in to comment