Skip to content

Commit

Permalink
fix(devcontainer): delete users group from container
Browse files Browse the repository at this point in the history
in `Dockerfile`, because the `updateRemoteUserUID` setting of the
devcontainer does not change the `GID` of the `containerUser`
dynamically to the one of the host user if the group exists in the
container already microsoft/vscode-remote-release#2402.

In our case the `containerUser` is set to `bitbots`, because it
automatically uses the last `USER` instruction from the `Dockerfile` and
the `remoteUser` inherits from `containerUser`.

For reference see: microsoft/vscode-remote-release#1155
  • Loading branch information
texhnolyze committed Jun 20, 2024
1 parent c180773 commit e9c612d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ RUN python3 -m pip install \
# Set zsh as default shell
SHELL ["/bin/zsh", "-c"]

# Create user bitbots with home directory and add to sudo group
RUN useradd -m -U -u "$uid" -G sudo -s /bin/zsh $user \
# Remove the users group, because when it exists on the host system
# the devcontainer will not dynamically update the containerUser GID,
# when the host user is part of the users group.
# Then create a bitbots user with home directory and add allow it to use sudo
RUN groupdel users \
&& useradd -m -U -u "$uid" -G sudo -s /bin/zsh $user \
&& groupmod -g "$gid" $user \
&& echo "$user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Expand Down

0 comments on commit e9c612d

Please sign in to comment.