From e2f9cc7a3a539d39ea5e467d8104e7bdbbdff2c5 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 14 Jan 2024 19:05:12 -0600 Subject: [PATCH] container: Symlink /etc/{passwd,group} to /host When `tmpl` runs `systemd-sysusers` after generating the `sysusers.d` file for NUT, the `/etc/passwd` and `/etc/group` files on the host are created anew and replaced, which "breaks" the bind mount. Since new files are put in their place, the container and the host no longer see the same files. We can work around this by using a symbolic link for each file, pointing to the respective file in the `/host` directory (which is the host's `/` directory bind mounted into the container's namespace). Since the symlinks follow the file by name rather than inode, the container's view is always in sync with the host's. --- Containerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Containerfile b/Containerfile index 2cc4f0e..197c43d 100644 --- a/Containerfile +++ b/Containerfile @@ -29,6 +29,8 @@ RUN --mount=type=cache,target=/var/cache \ age \ gcc \ git \ + && ln -snf /host/etc/passwd /etc/passwd \ + && ln -snf /host/etc/group /etc/group \ && cp -a /build/usr/local/bin/. /usr/local/bin \ && for cmd in \ systemctl \