Skip to content

Commit 653d2fc

Browse files
authored
Run as a non-root user
Running as a non-root user is a security best practice. Some environments require containers run as non-root users. For the `USER` directive, a numeric uid is specified instead of the username because systems configured to disallow running images as root aren't able to run images that use user name string values for the `USER` because they can't validate that a named user isn't root. See kubernetes/kubernetes#56503 for details.
1 parent 406322e commit 653d2fc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ COPY LICENSE \
77
requirements.txt \
88
/code/
99

10-
RUN pip install -r /code/requirements.txt
10+
RUN pip install -r /code/requirements.txt \
11+
&& addgroup -g 1000 codespell \
12+
&& adduser -u 1000 -G codespell -s /bin/sh -D codespell
13+
14+
USER 1000
1115

1216
ENTRYPOINT ["/code/entrypoint.sh"]
1317
CMD []

0 commit comments

Comments
 (0)