Run container image as non-root user by default.#288
Run container image as non-root user by default.#288r-xyz wants to merge 9 commits intousnistgov:masterfrom
Conversation
After installing additional pip packages, the container will adjust required permissions and run both django-admin and gunicorn commands as user `nemo:nemo`. UID and GID are 963 by default, but can be set using Docker Environment variables `PUID` and `GUID`, without need to recompile the image.
|
if another default |
|
Made some improvements. |
|
Hi and thank you for this. A few questions I have while I am trying to understand this:
|
|
Hi Mathieu,
Warning On container startup, anything mounted under Alternatively, we can remove runtime ownership change and leave to the admin to change ownership of |
| RUN addgroup --system --gid 963 nemo && \ | ||
| adduser --system --home /home/nemo --shell /usr/bin/bash --gid 963 --uid 963 --comment "NEMO user" nemo |
There was a problem hiding this comment.
is there a reason why we cannot define the PGID and PUID here as ENV and then use them with adduser and addgroup?
This PR introduces rootless Docker image as default.
After installing additional pip packages, the container will adjust required permissions and run both django-admin and gunicorn commands as user
nemo:nemo.UID and GID are 963 by default, but can be set using Docker Environment variables
PUIDandGUID, without need to recompile the image.Same changes can be ported to splash_pad image, though it will also require to define logging on different file than
/var/log/journal.Running as non-root should have no drawback in functionality, since I had already been running rootless instances, with custom built images. This PR willl simplify non-root usage and make it default for all users, adding an extra security layer.
If really required for backward compatibility or troubleshooting, setting PUID/GUID as 0/0 will run as
root:root.