Allows specifying another user to have zsh installed for within environment using -u argument#28
Open
balancedscorpion wants to merge 7 commits into
Open
Allows specifying another user to have zsh installed for within environment using -u argument#28balancedscorpion wants to merge 7 commits into
balancedscorpion wants to merge 7 commits into
Conversation
c2af006 to
8b36095
Compare
added 4 commits
July 29, 2024 21:28
… os, then user the appropriate add user command for each distribution to run the test correctly
Updated the call to main robyrussel script
Author
|
PR is now ready for review and if ok with it to be merged. |
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
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.
This change allows running zsh in a docker container for a non-root user
This addresses the issue described in #27
Primary changes:
1. User Specification:
Added a new option -u to specify the target user.
This defaults to the user running the script (usually root) by introducing TARGET_USER variable, defaulting to the current user:
TARGET_USER=$(whoami)2. Home Directory Determination
Replaced hardcoded home directory with dynamic determination, which changes depending on the target user.
TARGET_HOME=$(getent passwd "$TARGET_USER" | cut -d: -f6)Testing
I have tested this works for both no argument (default) and a user argument.
Here's the changes required in docker to the script that I used for testing:
Default (no user argument):
No changes are required to the script. But I used my fork to test it:
Specified user
When changing the user, I've first created a user, then added the -u argument (sample credentials below)
RUN sh -c "$(curl -L https://raw.githubusercontent.com/balancedscorpion/zsh-in-docker/new_user/zsh-in-docker.sh)" --
-u dockeruser \
Then to close out the Dockerfile: