-
Notifications
You must be signed in to change notification settings - Fork 2k
Change uid of www-data user before starting apache #286
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
Closed
Vampouille
wants to merge
3
commits into
docker-library:master
from
Vampouille:add_configuration_for_uid
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
|
|
||
| COPY docker-entrypoint.sh /docker-entrypoint.sh | ||
| COPY docker-entrypoint.d /docker-entrypoint.d | ||
|
|
||
| COPY apache2-foreground /usr/local/bin/ | ||
| WORKDIR /var/www/html | ||
|
|
||
| EXPOSE 80 | ||
| CMD ["apache2-foreground"] | ||
|
|
||
| ENTRYPOINT [ "/docker-entrypoint.sh" ] | ||
|
|
||
| CMD [ "apache2-foreground" ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # current www-data UID | ||
| CURRENT_UID=`id -u www-data` | ||
| WANTED_UID=${RUN_AS_UID:-33} | ||
|
|
||
| # check if UID need to be updated | ||
| if [ $CURRENT_UID -ne $WANTED_UID ]; then | ||
| echo "Updating www-data UID to $WANTED_UID" | ||
| usermod --non-unique --uid $WANTED_UID www-data | ||
| chown -R www-data /run/apache2 /run/lock/apache2 /var/cache/apache2/mod_cache_disk /var/log/apache2 | ||
| fi | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
| DIR=/docker-entrypoint.d | ||
|
|
||
| if [[ -d "$DIR" ]] | ||
| then | ||
| /bin/run-parts --verbose "$DIR" | ||
| fi | ||
|
|
||
| exec "$@" |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using this same code in a different docker image to change the
www-dataUID and needed to tweak this line toif [ "$CURRENT_UID" -ne "$WANTED_UID" ]; then, and the above toWANTED_UID=${RUN_AS_UID}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CURRENT_UIDandWANTED_UIDshould not be empty because :idcommand always return numeric identifier${RUN_AS_UID:-33}use 33 as default value ifRUN_AS_UIDis not setCan you explain steps to reproduce your issue, maybe your
www-datadefault uid was not set to 33.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vampouille that makes sense.. I'm not clear why the ID was not set by default on my instance, but based on what you're saying it doesn't seem like this change needs to be made. Thanks for taking the time to respond!