Skip to content

Commit

Permalink
Remove ubuntu user from Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
matifali committed Sep 19, 2024
1 parent bef9eff commit 01aa039
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions images/base/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ RUN ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose
# Make typing unicode characters in the terminal work.
ENV LANG=en_US.UTF-8

# Add a user `coder` so that you're not developing as the `root` user
RUN useradd coder \
# Remove the `ubuntu` user and add a user `coder` so that you're not developing as the `root` user
RUN deluser --remove-home ubuntu && \
useradd coder \
--create-home \
--shell=/bin/bash \
--groups=docker \
Expand Down
8 changes: 6 additions & 2 deletions images/minimal/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ RUN apt-get update && \
sudo \
&& rm -rf /var/lib/apt/lists/*

RUN useradd coder \
# Make typing unicode characters in the terminal work.
ENV LANG=en_US.UTF-8
# Remove the `ubuntu` user and add a user `coder` so that you're not developing as the `root` user
RUN deluser --remove-home ubuntu && \
useradd coder \
--create-home \
--shell=/bin/bash \
--groups=docker \
--uid=1001 \
--user-group && \
echo "coder ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers.d/nopasswd

ENV LANG=en_US.UTF-8
USER coder

0 comments on commit 01aa039

Please sign in to comment.