-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
In the docker guides(https://nodejs.org/en/docs/guides/nodejs-docker-webapp/) we show how to make a basic Dockerfile and run apps in a container using docker.This is great because containers are becoming more of a regular workflow. That said, in most cases it's not a good idea to run the containerized app as root because of security issues with the app actually having that same access to it's host. Threads have been going in relation to this topic in other groups .
see nodejs/docker-node#1
and here is the official Docker input on this
https://docs.docker.com/engine/articles/dockerfile_best-practices/#user
So should we make this aware on the Docker guide page to at least just to spread best practice. A sample Dockerfile that makes a "node" user and group and runs app as user "node"
FROM node:argon
ENV user node
RUN groupadd -r $user && useradd -r -g $user $user
# Create app directory
RUN mkdir -p /$user/src/app
WORKDIR /$user/src/app
# Install app dependencies
COPY package.json /$user/src/app/
RUN npm install
# Bundle app source
COPY . /$user/src/app
RUN chown -R $user:$user /$user/src/app/
USER $user
EXPOSE 8080
CMD [ "npm", "start" ]