Harden Dockerfile security with non-root user#1031
Harden Dockerfile security with non-root user#1031RinZ27 wants to merge 2 commits intotensorflow:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Dockerfile to improve security by creating and switching to a non-root user 'tfq-user' and setting the working directory to the user's home. The review feedback suggests explicitly defining the User ID (UID) and Group ID (GID) for the new user to ensure consistency across build environments and prevent potential permission issues with volume mounts.
8ca7681 to
54e071d
Compare
|
Thank you for your contribution. The way the changes to Dockerfile are done in this PR means that at run time, the user inside the Docker environment does not have access to file systems mounted when the Docker container is started. (An example of where that's needed is I also don't know how to solve the problem without putting a requirement on how the docker container is run. On balance, I wonder whether this is worth pursuing futher. It's true that there is this security issue, but because these Docker containers are meant for testing purposes by developers on their local systems, and are not distributed anywhere, the dangers are pretty limited. So, unless you can think of a simple solution to the problem of matching user id's, I would recommend closing this. |
|
@mhucka Since these containers are primarily for internal dev and testing, I agree that the simplicity of the current root setup is likely more practical than adding the overhead of dynamic UID handling. Closing this to keep the project workflow clean. |
Refactoring the module loading logic in
load_module.pyto useexcept Exception:instead of a bareexcept:. Correcting this prevents catching system-level signals likeKeyboardInterrupt, which I noticed was a potential reliability issue in the original implementation.