Replies: 2 comments
-
|
I guess I look at it inversely; is there any reason to build with privileges? I cant think of anything offhand unless your containerfile needs specific privileges. |
Beta Was this translation helpful? Give feedback.
-
|
I would separate two concerns: the user used while building the image, and the user used by the final running container. For Podman rootless builds, UID 0 inside the build container is mapped through a user namespace, so it is not the same as real host root. That reduces the host-risk side of the question. But it does not mean the final image should run as root. A common pattern is: For Python, the same idea applies: install OS packages or system-level dependencies as root if needed, then copy/chown the app and switch to a non-root user in the final stage. So my rule of thumb is:
So yes, there are still security and correctness benefits, but I would not force every build step to be non-root. Focus on the final runtime image first. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Apologies if I have somehow missed the answer to this elsewhere but I can't seem to find one for podman specifically.
When building images using a containerfile, is it still best practice to run as a non root user? E.g. for node npm ci/pythons pip install?
Presumably if so, rather than using userns=keep-id you would instead map it to the non root user created inside?
Does this have security benefits to do it as a non root user, considering root is in fact just your user account anyway outside of the container?
Thanks for your time
Beta Was this translation helpful? Give feedback.
All reactions