Skip to content

Commit c3cd0cb

Browse files
committed
Make devcontainer use non-root user.
1 parent 780a336 commit c3cd0cb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.devcontainer/devcontainer.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/python-3-miniconda
33
{
44
"name": "pandas",
5+
"containerUser": "pandas-dev",
56
"context": "..",
67
"dockerFile": "../Dockerfile",
78

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ RUN apt-get install -y libhdf5-dev
1010
RUN python -m pip install --upgrade pip
1111
RUN python -m pip install \
1212
-r https://raw.githubusercontent.com/pandas-dev/pandas/main/requirements-dev.txt
13+
14+
ARG USERNAME=pandas-dev
15+
ARG USER_UID=1000
16+
ARG USER_GID=$USER_UID
17+
RUN groupadd --gid $USER_GID $USERNAME \
18+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
19+
&& apt-get install -y sudo \
20+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
21+
&& chmod 0440 /etc/sudoers.d/$USERNAME
22+
1323
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)