Coder.comC
Coder.com2y 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}


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}
Was this page helpful?