From 6b66731850d11fef8798d96c14bf4956a60fbf0d Mon Sep 17 00:00:00 2001 From: Guiorgy Date: Mon, 4 Aug 2025 14:21:49 +0400 Subject: [PATCH] docker: Use fixed UID/GID for daemon users Currently, we rely on Debian to pick a UID and GID for daemon users. However, those numbers can change as software evolves over time, in particular as the base distribution changes. Because those IDs are relevant in the data volume, which has a lifetime independent from the daemon container, it is important that they don't change. Other projects have run into this issue over the years too, this is not a purely theoretical concern. This patch fixes the UID/GIDs for the daemon users to their current values, to prevent problems in the future. See https://github.com/albertito/chasquid/pull/72 for further discussion. Amended-by: Alberto Bertogli Adjusted commit message, formatted RUN command line, changed the dovecot group ID to match the previous value. --- docker/Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3b2d709..73af700 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,12 +17,19 @@ RUN go get -d ./... && \ # Create the image. FROM debian:stable-slim +# Create the chasquid and dovecot users with fixed UID/GID. # Install the packages we need. # This includes chasquid, which sets up good defaults. # Make debconf/frontend non-interactive, to avoid distracting output about the # lack of $TERM. -RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update -q && \ +RUN \ + groupadd -g 101 chasquid && \ + useradd -m -u 100 -g 101 -s /usr/sbin/nologin -d /var/lib/chasquid \ + chasquid && \ + groupadd -g 103 dovecot && \ + useradd -m -u 101 -g 103 -s /usr/sbin/nologin -d /usr/lib/dovecot \ + dovecot && \ + DEBIAN_FRONTEND=noninteractive apt-get update -q && \ apt-get install -y -q \ chasquid \ dovecot-lmtpd dovecot-imapd dovecot-pop3d \