I'm trying to run python code from docker using Visual Studio Code extension Remote Container. Here is the Dockerfile:
FROM python:3.8-slim-buster
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
ENV BLOB_CONTAINER_SAS_CONNECTION="secret"
ENV ROUND_LEVEL="0"
# Install pip requirements
ADD requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY [ ".env", "/app"]
ADD /src/sample_code_round_data_docker.py /app
# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
ARG USERNAME=someuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "sample_code_round_data_docker.py"]
And here is .devcontainer.json:
{
"name": "Existing Dockerfile",
"context": "..",
"dockerFile": "Dockerfile",
"settings": {
"terminal.integrated.shell.linux": null
},
"extensions": [],
"remoteUser": "someuser"
}
When i run it, it throws an error:
Shell server terminated (code: 126, signal: null)
unable to find user someuser: no matching entries in passwd file
When I search for the passwd file inside container:
cat /etc/passwd
There is no user someuser