Repository navigation
Add node group/user with gid/uid 1000 and a home directory - #263
Conversation
|
Hi guys, I am interested in this as I have a similar solution to fix rights on files generated inside a container (e.g I favored using an My solution does not work yet for every scenarii that I have (see above, note that current #!/bin/bash
user=$(whoami)
if [ $user != "root" ]; then
cat >&2 <<-EOINFO
INFO: A user has been specified. Default root is
needed in order to perform group and user ids
modifications.
Do NOT use "-u <username>" in "docker run".
****************************************************
EOINFO
else
username="robert_paulson"
if [ "$USER_ID" ]; then
uid="$USER_ID"
else
cat >&2 <<-'EOINFO'
INFO: No uid as been specified, 1000 will be used by
default.
Use "-e USER_ID=1042" to set it in "docker run".
****************************************************
EOINFO
uid=1000
fi
if [ "$GROUP_ID" ]; then
gid="$GROUP_ID"
else
cat >&2 <<-'EOINFO'
INFO: No gid as been specified, 1000 will be used by
default.
Use "-e GROUP_ID=1042" to set it in "docker run".
****************************************************
EOINFO
gid=1000
fi
groupadd -g $gid $username
useradd -u $uid -g $gid -G node --create-home $username
fi
su -c "$@" $usernameEDIT The problem was in the way I called Here are my implementation (Dockerfile, and entrypoint), and some code using it. Hope this can be useful. |
|
I'd like |
|
Could you update the alpine variant as well? |
|
@LaurentGoderre I've added the same change to the Alpine variant. |
|
Not sure about the Alpine change, I'm not very familiar with it. Can another @nodejs/docker member please take a look as well? |
|
Actually @blueimp can you please make one more change? Currently the added user (on the non-Alpine variants) has the shell set to (This does not apply to the Alpine variant, as its shell is provided by Busybox) |
|
@pesho done. :) |
|
This is awesome!! |
|
Sorry @Starefossen , @SimenB just noticed one line which is uneccessary, so I'll do one new commit. |
This is a workaround for boot2docker issue 581, see boot2docker/boot2docker#581
|
Done. |
|
It looks like this is good to be merged. @nodejs/docker Any objections? |
|
👍 |
|
Merging as there have been 4 approvals and no objections so far. |
|
I think we should wait until the next Node.js tagged release to push this into the Docker library, as it could break some images which already use the |
|
Sounds good. I'll do it as part of the v7.2.0 release. |
|
This merge and #261 broke the functionality in my gyeh/purescript containers on docker hub. Before, you could do something like I filed a ticket for this at the docker repo, but I just thought I should mention this as a heads up as this could be a problem for users relying on similar functionality when composing this container. |
|
We're tracking that here: #289 |
Available since nodejs/docker-node#263 .
This is a workaround for docker-machine/boot2docker issue 581, see
boot2docker/boot2docker#581
Although Docker for Mac/Windows doesn't have this issue, there are still many developers using docker-machine with VirtualBox+NFS for performance reasons.
Using a normal user with a home directory instead of a system user faciliates usage of the docker images as e.g. installing packages can simply done in the home directory.