Skip to content

Ability to change username inside the docker container? #881

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
linuxd3v opened this issue Aug 1, 2019 · 10 comments
Closed

Ability to change username inside the docker container? #881

linuxd3v opened this issue Aug 1, 2019 · 10 comments
Assignees
Milestone

Comments

@linuxd3v
Copy link

linuxd3v commented Aug 1, 2019

Hi. it would be nice to be able to pass in the username and uid|gid as environmental variables when launching container.

So we dont have to use a name coder and use something specific to the user.

@deansheather
Copy link
Member

You could replace the entrypoint in your image with a script that changes the username to something stored in an env variable. Something like the following should work (untested):

#!/bin/sh
usermod -l coder $CODER_USER
/usr/bin/dumb-init /usr/local/bin/code-server

This won't change the home directory from /home/coder to /home/deansheather though.

@avaidyam
Copy link

@loganto @deansheather It's a bit late but here's the script I'm using (allows configuring VS_UID, VS_GID, and VS_USERNAME):

!/usr/bin/dumb-init /bin/sh
groupadd --gid ${VS_GID:-1000} $VS_USERNAME
adduser --uid ${VS_UID:-1000} --gid ${VS_GID:-1000} --home /home/${VS_USERNAME:-coder} --gecos '' --disabled-password ${VS_USERNAME:-coder}
echo "${VS_USERNAME:-coder} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
cd /home/${VS_USERNAME:-coder}
runuser --login ${VS_USERNAME:-coder} --session-command="PASSWORD=$PASSWORD code-server --disable-telemetry --host 0.0.0.0 $@"

This really should be baked in by default.

@nhooyr
Copy link
Contributor

nhooyr commented Jul 20, 2020

Not sure why you need all that, just use:

sudo usermod -l nhooyr coder
sudo usermod -d /home/nhooyr -m nhooyr

For example to set it the username to nhooyr.

@nhooyr
Copy link
Contributor

nhooyr commented Jul 20, 2020

And you can already adjust the uid/gid you run the image as and the image will automatically change the coder user to reflect that uid/gid.

@avaidyam
Copy link

You have a good point, but I would like this to be merged into the code-server upstream image. My script was a quick hack just to get things working.

@nhooyr nhooyr reopened this Jul 20, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Jul 20, 2020

Let's add a environment variable to configure it!

@avaidyam
Copy link

@nhooyr Any progress on this? Or am I expected to submit a PR...?

@nhooyr
Copy link
Contributor

nhooyr commented Aug 17, 2020

I'll take care of it soon.

@nhooyr nhooyr self-assigned this Aug 25, 2020
@nhooyr nhooyr added this to the v3.5.0 milestone Aug 25, 2020
nhooyr added a commit that referenced this issue Aug 25, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
@nhooyr
Copy link
Contributor

nhooyr commented Aug 25, 2020

#2001

nhooyr added a commit that referenced this issue Aug 25, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description
now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description now.

Closes #881
nhooyr added a commit that referenced this issue Aug 26, 2020
Needs to be reflected in the documentation and the dockerhub description now.

Closes #881
nhooyr added a commit that referenced this issue Aug 27, 2020
Needs to be reflected in the documentation and the dockerhub description now.

Closes #881
@nhooyr
Copy link
Contributor

nhooyr commented Aug 31, 2020

@nhooyr nhooyr closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants