Reputation: 807
I am using docker node node:alpine
for building the container but i would like to start my node application as non root user.
Just adding the user and group using adduser
and addgroup
is increasing the size of image by 300MB compared to when running as root user.
Using shadow
from alpine testing repo also does the same (i.e. increases the size of my image by 300MB).
RUN echo http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
Any tools or any suggestions how to create non root user with considerably not increasing the size of image too much ?
Upvotes: 2
Views: 4805
Reputation: 46
Since I can't comment, please by all means ignore the answer of Sergey Yarotskiy. This is a dangerous misleading answer, which is also wrong.
Read for example https://medium.com/@mccode/processes-in-containers-should-not-run-as-root-2feae3f0df3b to why you should NEVER run as root in your containers unless you really explicitly need to.
However you can instead run your container with docker run -u to specify the user manually.
Upvotes: 2