Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't be running node as root? #6

Closed
NodeGuy opened this issue Feb 3, 2015 · 4 comments
Closed

Shouldn't be running node as root? #6

NodeGuy opened this issue Feb 3, 2015 · 4 comments

Comments

@NodeGuy
Copy link

NodeGuy commented Feb 3, 2015

Apologies if this is a FAQ, my Google-fu didn't turn up any answers.

Isn't it a bad idea that we're running node as the root user by default? I'm currently crafting Dockerfiles for my company's products and am curious about what the best practice is for this issue.

@rmustacc
Copy link

rmustacc commented Feb 3, 2015

Does #1 answer your question?

@NodeGuy
Copy link
Author

NodeGuy commented Feb 3, 2015

Not really, but thank you for linking to it.

Docker's Best practices for writing Dockerfiles reads, "If a service can run without privileges, use USER to change to a non-root user." I think we should do that it.

I opted to create my own version of the -onbuild Dockerfile:

FROM node:0.10

# Copy steps from -onbuild because we don't want to run as root.

ENV user node
RUN groupadd --system $user && useradd --system --create-home --gid $user $user

COPY . /home/$user/
WORKDIR /home/$user
RUN chown $user --recursive .
USER $user
RUN npm install

CMD [ "npm", "start" ]

@chorrell chorrell self-assigned this Feb 3, 2015
@chorrell
Copy link
Contributor

There's an ongoing discussion about this in #1

For now, creating your own Dockerfile is the way to role if you're concerned about running things as root.

@chorrell
Copy link
Contributor

Closing as a dupe of #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants