Looks like the official docker images for Ubuntu 24.04 ship with a user named ubuntu. While the user name is largely immaterial, the choice of UID/GID 1000 for this default user is a bit disruptive, given it's addition as compared to 22.04. E.g:
--- jammy
+++ noble
@@ -1,4 +1,4 @@
-$ docker run -it --rm ubuntu:22.04 cat /etc/passwd
+$ docker run -it --rm ubuntu:24.04 cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
@@ -15,6 +15,6 @@
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
-gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
+_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
-_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
+ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
For example, I know a lot of docker related tools, such as the devcontainer CLI, attempt to automatically remap the UID/GID of a container user to match that of the host user, simplifying permissions for bind mounts when sharing files across container and host via volumes. However, most developers already have their user account set to UID/GUI 1000, given that's default when creating an initial host account. Thus, these tools can oddly fail to remap the UID/GID properly during container bringup, leaving developers perplexed when tools regess without having changed any docker container run arguments.
Currently I create a pseudo dever account for any devcontainer tool to latch onto and remap UID/GID via the parameter "remoteUser": "dever", in the devcontainer.json config file.
FROM base as dever
add default user for devcontainer
RUN useradd
--create-home
--gid root
--groups sudo
--no-log-init
--shell /bin/bash
--system
dever &&
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
Given how only some ubuntu images now ship with a ubuntu user that squats ontop the UID/GID 1000, what alternatives approaches would others recommend when creating an agnostic Dockerfile to remap any normal user UID/GID at bringup? Must I now alway just check for an existing UID of 1000 to generalize across ubuntu base image version?