Skip to content

Commit 0edff6b

Browse files
authored
Merge pull request #575 from eclipse-tractusx/docs/trg-403-align-on-userid
docs: adjust trg 4.03 on userid
2 parents d789b21 + e268a21 commit 0edff6b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

docs/release/trg-4/trg-4-03.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: TRG 4.03 - Non-root container
44

55
| Status | Created | Post-History |
66
|--------|--------------|----------------------------------|
7+
| Active | 04-Jan-2024 | Adjust user ids |
78
| Active | 29-Dec-2022 | Initial Release |
89
| Draft | 14-Sept-2022 | Draft |
910

@@ -19,14 +20,19 @@ For security reasons this is **must** be followed.
1920

2021
The container's **Dockerfile** and the **Pod resource file (yaml)** has to be modified to be able to run as a non-root user.
2122

22-
- Modify the image's Dockerfile with a `RUN` command that adds a non-root user and a `USER` command that specifies which user runs the container on startup. The example below can be modified for specific needs/requirements.
23+
- First it is recommended to check how the base image is built to see if it
24+
might already have a non-root user defined and used. In this case it is enough
25+
to specify that user in the Dockerfile with the `USER` instruction.
26+
- Otherwise modify the image's Dockerfile with a `RUN` command that adds a non-root user
27+
and a `USER` command that specifies which user runs the container on startup.
28+
The example below can be modified for specific needs/requirements.
2329

2430
```Dockerfile
2531
#Pull the base image as Ubuntu
2632
FROM ubuntu:latest
2733

28-
#Add a user with userid 8877 and name nonroot
29-
RUN useradd −u 8877 nonroot
34+
#Add a user with userid 1000 and name nonroot
35+
RUN useradd −u 1000 nonroot
3036

3137
#Run Container as nonroot
3238
USER nonroot
@@ -46,6 +52,5 @@ spec:
4652
- name: example-container
4753
image: gcr.io/google-samples/node-hello:1.0
4854
securityContext:
49-
runAsUser: 1000 # SPECIFY USER ID HERE
5055
allowPrivilegeEscalation: false # SET THIS TO FALSE
5156
```

0 commit comments

Comments
 (0)