Skip to content

Instantly share code, notes, and snippets.

@saku
Last active April 17, 2022 04:33
Show Gist options
  • Save saku/887407eda437a04acf295f9953e8c854 to your computer and use it in GitHub Desktop.
Save saku/887407eda437a04acf295f9953e8c854 to your computer and use it in GitHub Desktop.
Ubuntu with default user who can use sudo unless password.
FROM ubuntu
ARG USERNAME=user
ARG USERPASS=user
ARG GROUPNAME=user
ARG UID=1000
ARG GID=1000
RUN apt -y update && apt install -y sudo
RUN groupadd -g $GID $GROUPNAME && \
useradd -m -s /bin/bash -p $USERPASS -u $UID -g $GID $USERNAME && \
gpasswd -a $USERNAME sudo && \
echo "$USERNAME:$USERPASS" | chpasswd && \
echo "user ALL=NOPASSWD: ALL" >> /etc/sudoers
USER $USERNAME
WORKDIR /home/$USERNAME/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment