Categories
JavaScript Answers

How to run app inside Docker as non-root user?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *