From df197de18758cb3dbdb0ad779d8983240a27d67c Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Thu, 9 Jan 2025 17:17:34 +0000 Subject: [PATCH] Remove need for password for user chaste --- Dockerfile | 6 ++++-- README.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e466601..1d30d3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,7 +85,7 @@ ENV USER=${USER} \ GROUP=${USER} \ UID=${UID} \ GID=${UID} \ - PASSWORD=${USER} \ + # PASSWORD=${USER} \ CHASTE_DIR=${CHASTE_DIR} \ CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ Chaste_ERROR_ON_WARNING=${Chaste_ERROR_ON_WARNING} \ @@ -108,7 +108,9 @@ RUN userdel -r ubuntu || true # RUN useradd -ms /bin/bash ${USER} && echo "${USER}:${PASSWORD}" | chpasswd && adduser ${USER} sudo RUN groupadd -g ${GID} ${GROUP} && \ useradd -ms /bin/bash -u ${UID} -g ${GID} -d ${CHASTE_DIR} ${USER} -G users,sudo && \ - echo "${USER}:${PASSWORD}" | chpasswd + # echo "${USER}:${PASSWORD}" | chpasswd + echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} && \ + chmod 0440 /etc/sudoers.d/${USER} # Add scripts COPY --chown=${USER}:${GROUP} scripts "${CHASTE_DIR}/scripts" diff --git a/README.md b/README.md index 2934aac..250fb08 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ If you want to use a package which is not installed within the image, you can in ``` sudo apt-get update && sudo apt-get install ``` -Replacing `` as appropriate. Enter the password: `chaste` when prompted to do so. +Replacing `` as appropriate. The default user `chaste` has `sudo` privileges and is set to need no password. Note that packages installed this way will not persist after the container is deleted (because the relevant files are not stored in `/home/chaste`). This can be avoided by omitting the `--rm` flag from the `docker run` command and using `docker start ` to relaunch a previously used container. If there is a package you think would be a particularly useful permanent addition to the Docker image, then email your suggestion to me or submit a pull request.