-
Notifications
You must be signed in to change notification settings - Fork 203
Run containers as non-root user with Docker --user support #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brycelelbach
wants to merge
24
commits into
main
Choose a base branch
from
non-root
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+528
−276
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
❌ Link Check FailedBroken links were detected in this PR. Please check the workflow run logs for details on which links are broken. Common fixes:
To test links locally:./brev/test-links.bash . |
598c498 to
154fc9b
Compare
…tup and cleanup functions, replacing them with environment variable exports for user ID and group ID. Adjust Docker Compose files to set user permissions dynamically based on host user. Introduce user-setup script for runtime environment configuration.
…up.bash since it's sourced via BASH_ENV and affects all subsequent scripts. Use safe parameter expansion in jupyter-start.bash. Configure nsight service to start as root but switch to HOST_UID via USER environment variable. Add USER to common-service environment block for all containers.
…p.bash to user-env.bash and dev-mount.bash to dev-common.bash. Add shell-start.bash for interactive shell sessions.
…specific scripts.
… and directories.
…add restart-loop detection to tests.
…it fails with NFS root squashing.
…mission errors in the Nsight service.
…ontainer doesn't have it.
262e7d4 to
38fc952
Compare
…tor add example for comparison, improve benchmarking, and add parameter sweeping.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the Docker container setup to run as a non-root user, improving security while maintaining full functionality. The implementation uses a unified entrypoint system with
gosufor user switching and preserves passwordless sudo for operations that require root privileges.Key Changes
Unified Entrypoint Architecture
brev/entrypoint.bash- Main dispatcher that handles user creation and delegates to service-specific scriptsentrypoint-base.bash,entrypoint-jupyter.bash,entrypoint-nsight.bash,entrypoint-shell.bashentrypoint-base-user.bash,entrypoint-jupyter-user.bash(run as target user viagosu)User Management
ACH_UID/ACH_GID/ACH_USERenvironment variables (defaults to UID 1000)gosufor secure user switching (avoids TTY and signal issues withsudo)Development Environment
brev/dev-common.bashreplacesdev-mount.bash- ExportsACH_UID/ACH_GID/ACH_USERfor Docker Composedev-start.bash,dev-stop.bash,dev-test.bashscriptsDocker Configuration
gosuandsudouser: root(entrypoint handles user switching)ACH_USER,ACH_UID,ACH_GIDpassed through environmentNsight Streamer Integration
entrypoint-nsight.bashruns as root, sets up environment, then delegates to nsight streamer's own entrypointProfiling Tools
nsysandncuwithsudofor full profiling capabilitiesBugfixes
scikit-learnversion in accelerated-python tutorial for cuML compatibilitydocker-recipe.pyfor stdpar tutorialFiles Modified
New files:
brev/entrypoint.bash- Main entrypoint dispatcherbrev/entrypoint-base.bash,entrypoint-jupyter.bash,entrypoint-nsight.bash,entrypoint-shell.bash- Service entrypointsbrev/entrypoint-base-user.bash,entrypoint-jupyter-user.bash- User-level scriptsbrev/dev-common.bash- Development environment helpersRemoved files:
brev/dev-mount.bash- Replaced bydev-common.bashbrev/nsight-start.bash- Replaced byentrypoint-nsight.bashbrev/base-start.bash,brev/jupyter-start.bash- Renamed toentrypoint-*-user.bashUpdated files:
brev/dev-start.bash,brev/dev-stop.bash,brev/dev-test.bash,brev/dev-shell.bashbrev/jupyter-generate-plugin-settings.bashCONTRIBUTING.md- Removed bindfs referencessudofor profiling toolsBenefits