Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(docker): pin posthog user to fixed uid with home directory (#60779)

Tom Piccirello605852b0d1f6
diff --git a/Dockerfile b/Dockerfile
index 820169eeb903..420457b4a856 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -295,8 +295,9 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& rm -rf /tmp/*
# Install and use a non-root user.
-RUN groupadd -g 1000 posthog && \
- useradd -r -g posthog posthog && \
+# Pin uid/gid to a fixed, host-safe value (avoid 1000, which maps to ec2-user on the nodes).
+RUN groupadd -g 10001 posthog && \
+ useradd -u 10001 -g posthog -m -d /home/posthog -s /bin/bash posthog && \
chown posthog:posthog /code
USER posthog
diff --git a/Dockerfile.node b/Dockerfile.node
index 661888758d3f..04c47ff3ac19 100644
--- a/Dockerfile.node
+++ b/Dockerfile.node
@@ -110,8 +110,8 @@ RUN apt-get update && \
# gettext-base: Provides envsubst command used by bin/nodejs to substitute environment variables in Kafka client IDs
# Install and use a non-root user
-RUN groupadd -g 1000 posthog || groupmod -n posthog $(getent group 1000 | cut -d: -f1) && \
- useradd -u 1000 -g posthog posthog || usermod -l posthog -d /code -g posthog $(getent passwd 1000 | cut -d: -f1) && \
+RUN groupadd -g 10001 posthog && \
+ useradd -u 10001 -g posthog -m -d /home/posthog posthog && \
chown -R posthog:posthog /code
USER posthog
diff --git a/Dockerfile.recording-rasterizer b/Dockerfile.recording-rasterizer
index 5efaf591315c..b55234c9f255 100644
--- a/Dockerfile.recording-rasterizer
+++ b/Dockerfile.recording-rasterizer
@@ -128,8 +128,8 @@ RUN npx --yes @puppeteer/browsers install [email protected] \
--path /opt/chrome-headless-shell && \
ln -s "$(find /opt/chrome-headless-shell -name chrome-headless-shell -type f | head -1)" /usr/local/bin/chrome-headless-shell
-RUN groupadd -g 1000 posthog || groupmod -n posthog $(getent group 1000 | cut -d: -f1) && \
- useradd -u 1000 -g posthog posthog || usermod -l posthog -d /code -g posthog $(getent passwd 1000 | cut -d: -f1) && \
+RUN groupadd -g 10001 posthog && \
+ useradd -u 10001 -g posthog -m -d /home/posthog posthog && \
chown -R posthog:posthog /code
USER posthog