Distroless images comes with 3 users :
> docker run --rm --entrypoint cat gcr.io/distroless/nodejs:debug /etc/passwd
root:x:0:0:root:/root:/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin
nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin
If you run the image without a USER
instruction in your Dockerfile the image runs as uid=0(root) gid=0(root).
I would like to avoid this and use an unprivileged user.
Other than nobody not having a /home
directory, what is the difference between using USER nobody
and USER nonroot
in my Dockerfile ?