To run app inside Docker as non-root user, we add a user that doesn’t require a password to log in.
For instance, we run
adduser --disabled-password --gecos '' r
adduser r sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
su -m r -c /home/r/script.sh
to add the user with adduser
.
We add it to the list of users that can run sudo
with adduser r sudo
.
Then we run the command we want with su -m r -c /home/r/script.sh
.