Allows specifying another user to have zsh installed for within environment using -u argument #28
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: