Skip to content

Commit 80a32a6

Browse files
authored
Merge pull request #57 from oslokommune/un-root
Don't run Docker containers as root
2 parents 0c92811 + 24a7334 commit 80a32a6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
1515

1616
EXPOSE 8000
1717

18+
RUN groupadd -r app
19+
RUN useradd -r -g app app
20+
RUN chown -R app:app /usr/src/app/workdir
21+
USER app
22+
1823
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
1924
CMD ["python", "-m", "probe"]

local-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.2"
2-
31
networks:
42
probe:
53

local/http_server/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ RUN mkdir /usr/src/app/
55
COPY . /usr/src/app/
66
WORKDIR /usr/src/app/
77
RUN pip install flask
8+
9+
RUN groupadd -r app
10+
RUN useradd -r -g app app
11+
RUN chown -R app:app /usr/src/app
12+
USER app
13+
814
CMD ["python", "http_server.py"]

0 commit comments

Comments
 (0)