-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Support non-root users (runtime UID remapping) #640
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
Changes from 14 commits
5427f06
9fe6c36
051b5ea
09c5556
908d293
1504dfd
42bb4da
efe1ca8
70424c8
4878c74
3190626
08ca5be
81ec63b
7ed7305
b328da9
dfce54b
b232cc5
daa96b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/lib | ||
code-server | ||
node_modules | ||
dist | ||
out | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Docker launch commands for coder | ||
|
||
|
||
## default coder uid:guid | ||
docker run -it -p 127.0.0.1:8443:8443 \ | ||
-v "${PWD}/code-server:/home/coder/project" \ | ||
satlus-code-server:latest --allow-http --no-auth | ||
satlus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## passing `id(-g|-u)` through the system | ||
docker run -it -p 127.0.0.1:8443:8443 \ | ||
-v "${PWD}/code-server:/home/coder/project" \ | ||
-v "${PWD}/code-server/.cache:/home/coder/.cache" \ | ||
-v "${PWD}/code-server/.local:/home/coder/.local" \ | ||
-u $(id -u):$(id -g) \ | ||
satlus-code-server:latest --allow-http --no-auth | ||
satlus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,14 +34,24 @@ RUN locale-gen en_US.UTF-8 | |
# configured in /etc/default/locale so we need to set it manually. | ||
ENV LC_ALL=en_US.UTF-8 | ||
|
||
RUN adduser --gecos '' --disabled-password coder && \ | ||
RUN addgroup --gid 1000 coder && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by default the first user to be made in Docker build is 1000 already, I don't see the need for extra steps.
|
||
adduser --uid 1000 --ingroup coder --home /home/coder --shell /bin/sh --disabled-password --gecos "" coder && \ | ||
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd | ||
|
||
RUN USER=coder && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gosu is actually preferred as it mirrors
|
||
GROUP=coder && \ | ||
curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.4/fixuid-0.4-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ | ||
chown root:root /usr/local/bin/fixuid && \ | ||
chmod 4755 /usr/local/bin/fixuid && \ | ||
mkdir -p /etc/fixuid && \ | ||
printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml | ||
|
||
USER coder | ||
|
||
# We create first instead of just using WORKDIR as when WORKDIR creates, the user is root. | ||
RUN mkdir -p /home/coder/project | ||
RUN mkdir -p /home/coder/workdir | ||
|
||
|
||
WORKDIR /home/coder/project | ||
WORKDIR /home/coder/workdir | ||
satlus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
# This assures we have a volume mounted even if the user forgot to do bind mount. | ||
# So that they do not lose their data if they delete the container. | ||
|
@@ -50,4 +60,4 @@ VOLUME [ "/home/coder/project" ] | |
COPY --from=0 /src/packages/server/cli-linux-x64 /usr/local/bin/code-server | ||
EXPOSE 8443 | ||
|
||
ENTRYPOINT ["dumb-init", "code-server"] | ||
ENTRYPOINT ["dumb-init", "fixuid", "code-server"] |