From 893b24dfc399f8773257fcd144d37396db4d7510 Mon Sep 17 00:00:00 2001 From: Andrei Neculau Date: Tue, 9 Jul 2024 21:29:49 +0200 Subject: [PATCH] docker: revert back linuxbrew's UID to 1000 In https://github.com/Homebrew/brew/pull/17584 we have changed "linuxbrew" user's UID/GID to 1001 in order to mitigate for Ubuntu 23.04 and higher, which started creating a default "ubuntu" user taking over UID/GID 1000 . While we may desire a deterministic UID in the homebrew docker image, the change effectively modified the behaviour for all current 3 images based on Ubuntu 18.04 20.04 and 22.04 by changing the linuxbrew's user UID/GID from 1000 to 1001. As per https://hub.docker.com/u/homebrew, we do not currently publish an image for 24.04 which the change is mitigating for. Rather than mitigating for indeterministic behaviour of upstream changes, this commit implements the workaround in https://bugs.launchpad.net/cloud-images/+bug/2005129 to delete the default "ubuntu" user. --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e471752dca1d1..5a8bc9ea5886c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,11 @@ ARG version=22.04 FROM ubuntu:"${version}" ARG DEBIAN_FRONTEND=noninteractive -# Set the user ID to the default value of 1001 since different ubuntu -# versions yield to different user IDs with `useradd` -ENV USER_ID=1001 +# Deterministic UID (first user). Helps with docker build cache +ENV USER_ID=1000 +# Delete the default ubuntu user & group UID=1000 GID=1000 in Ubuntu 23.04+ +# that conflicts with the linuxbrew user +RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu; true # We don't want to manually pin versions, happy to use whatever # Ubuntu thinks is best.