Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit aef6926

Browse files
committed
Update UID/GID rather than create user
1 parent 4623f33 commit aef6926

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

containers/r/.devcontainer/Dockerfile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ FROM rocker/r-apt:bionic
88
# Avoid warnings by switching to noninteractive
99
ENV DEBIAN_FRONTEND=noninteractive
1010

11-
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
12-
# this user's GID/UID must match your local user UID/GID to avoid permission issues
13-
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
14-
# https://aka.ms/vscode-remote/containers/non-root-user for details.
15-
ARG USERNAME=vscode
16-
ARG USER_UID=1001
11+
# The r-apt image comes with a base non-root 'docker' user which this Dockerfile
12+
# gives sudo access. However, for Linux, this user's GID/UID must match your local
13+
# user UID/GID to avoid permission issues with bind mounts. Update USER_UID / USER_GID
14+
# if yours is not 1000. See https://aka.ms/vscode-remote/containers/non-root-user.
15+
ARG USER_UID=1000
1716
ARG USER_GID=$USER_UID
1817

1918
# Configure apt and install packages
@@ -33,13 +32,13 @@ RUN apt-get update \
3332
&& apt-get update \
3433
&& apt-get -y install dotnet-runtime-2.1 \
3534
#
36-
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
37-
&& groupadd --gid $USER_GID $USERNAME \
38-
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
35+
# [Optional] Update a non-root user to match UID/GID - see https://aka.ms/vscode-remote/containers/non-root-user.
36+
&& if [ "$USER_GID" != "1000" ]; then groupmod docker --gid $USER_GID; fi \
37+
&& if [ "$USER_UID" != "1000" ]; then usermod --uid $USER_UID docker; fi \
3938
# [Optional] Add sudo support for the non-root user
4039
&& apt-get install -y sudo \
41-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
42-
&& chmod 0440 /etc/sudoers.d/$USERNAME \
40+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/docker\
41+
&& chmod 0440 /etc/sudoers.d/docker \
4342
#
4443
# Clean up
4544
&& apt-get autoremove -y \

containers/r/.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Uncomment the next line to use a non-root user. On Linux, this will prevent
66
// new files getting created as root, but you may need to update the USER_UID
77
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
8-
// "-u", "vscode",
8+
// "-u", "docker",
99

1010
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
1111
],

0 commit comments

Comments
 (0)