This works, but the resultant image runs as root. How can I extend this example to add a non-root user (ideally with a specific UID/GID) and specify that the container runs with that user?
I haven’t tried this with Nix but Docker user is completely independent of the users on the host system where the container is built. So just specify any non-root user and it should work.
Thanks - so I was expecting to need to add a user inside the container (not on the host system) in order to be able to then run the image as that UID - perhaps using something like:
RUN useradd -m --uid=1000 -r -s /bin/bash cloudsdk
However, I was hoping to add a bit more setup for the user rather than just adopt a UID - in particular I wanted them to have a home directory they could write to. Is there a good recipe for doing that?
I don’t think you need anything special from Nix for that, just use runAsRoot instead of RUN with useradd to explicitly create a user’s home directory, configure groups etc., or just do an mkdir + chown to get a writeable directory.