C
Coder.com8mo ago
JFK

Local User w/Enterprise Container

When using a starter Docker template, the buildfile shown here, creates a local user that is the person who is logging into the workspace.
FROM ubuntu

RUN apt-get update \
&& apt-get install -y \
curl \
git \
golang \
sudo \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

ARG USER=coder
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
FROM ubuntu

RUN apt-get update \
&& apt-get install -y \
curl \
git \
golang \
sudo \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

ARG USER=coder
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
However when using the enterprise container creates a "coder" user, so that a user named "Fred" is now logged in as coder. I've tried updating the build file as such, but the build breaks with issues on the useradd command. Not really sure why.
FROM codercom/enterprise-base

ARG USER=coder
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
FROM codercom/enterprise-base

ARG USER=coder
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
6 Replies
Codercord
Codercord8mo ago
<#1227296455673385001>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Atif
Atif8mo ago
the enterprise image already has a user named coder and you do not need to add anew non-root user
JFK
JFKOP8mo ago
I want to add a user that isn't named "coder". I like the docker sample template because the user is named whatever they are named from the SSO.
Atif
Atif8mo ago
Ok. Then you need to add your new user with a diffrent uid The existing user has uid 1000 Can you share the error you get?
Phorcys
Phorcys8mo ago
hey @John King, could you share the error you're getting?
JFK
JFKOP8mo ago
**Error: process "/bin/bash -c useradd --create-home --home-dir /home/${USER} --groups sudo --shell /bin/bash ${USER} \t&& echo \"${USER} ALL=(ALL) NOPASSWD:ALL\" >/etc/sudoers.d/${USER} \t&& chmod 0440 /etc/sudoers.d/${USER}" did not complete successfully: exit code: 2**
**Error: process "/bin/bash -c useradd --create-home --home-dir /home/${USER} --groups sudo --shell /bin/bash ${USER} \t&& echo \"${USER} ALL=(ALL) NOPASSWD:ALL\" >/etc/sudoers.d/${USER} \t&& chmod 0440 /etc/sudoers.d/${USER}" did not complete successfully: exit code: 2**
Want results from more Discord servers?
Add your server