From 01aa039a38ea731a7c8deca1663c7a7249e88bc9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 19 Sep 2024 17:28:50 +0500 Subject: [PATCH] Remove `ubuntu` user from Dockerfiles --- images/base/ubuntu.Dockerfile | 5 +++-- images/minimal/ubuntu.Dockerfile | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/images/base/ubuntu.Dockerfile b/images/base/ubuntu.Dockerfile index af1cc16..5fbeb9a 100644 --- a/images/base/ubuntu.Dockerfile +++ b/images/base/ubuntu.Dockerfile @@ -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 \ diff --git a/images/minimal/ubuntu.Dockerfile b/images/minimal/ubuntu.Dockerfile index c9fce6f..3d4a12d 100644 --- a/images/minimal/ubuntu.Dockerfile +++ b/images/minimal/ubuntu.Dockerfile @@ -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