Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

can anyone explain me why I need this command?

I have seen a few tutorials about docker but then I saw this on a web page

FROM node:10-alpine

RUN mkdir -p /home/node/node_modules && chown -R node:node /home/node

WORKDIR /home/node

COPY package*.json ./

USER node

RUN npm install

COPY --chown=node:node . .

EXPOSE 8080

CMD [ "node", "app.js" ]

So why I need this and whats chown -R

RUN mkdir -p /home/node/node_modules && chown -R node:node /home/node

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your mkdir command creates a sub-folder within the node folder, and the chown -R command changes ownership of the folder to the user node recursively (the folder and all it’s contents).

This is required because the node app uses the node user to create files and folders in the /home/node directory. This is important from a cybersecurity perspective, especially if you don’t want the app running as an admin or root account.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading