-
Notifications
You must be signed in to change notification settings - Fork 445
Description
Background:
I am trying to install homebrew in my devcontainer's image for use by the non-root remoteUser, since the system package manager will be unusable. However, this won't work reliably:
ARG USERNAME=dev
RUN useradd -ms $(which bash) ${USERNAME}
ARG HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
COPY \
--from=docker.io/homebrew/brew:latest \
--chown=${USERNAME} \
${HOMEBREW_PREFIX} ${HOMEBREW_PREFIX}The problem is the automatic UID update (ie. the updateRemoteUserUID option). The update just modifies the UID:GID in the /etc/passwd file without actually changing ownership of anything, so the updated user no longer has access to HOMEBREW_PREFIX which is still owned by the pre-update UID:GID. So you can't use brew if the update executes. You could add ARGs for the host UID and GID (ie. what the update will change you to), but I'd prefer not to hardcode it in my dockerfile.
It would be better if we could add pre-defined variables for the host UID and GID which we could then add as build args via the build.args field. Making the remoteUser available as a pre-defined variable would also be helpful to avoid having to hardcode it in both devcontainer.json and the dockerfile.