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

httpd could be launch without root user in alpine container #118

Closed
bgauduch opened this issue Nov 15, 2018 · 2 comments
Closed

httpd could be launch without root user in alpine container #118

bgauduch opened this issue Nov 15, 2018 · 2 comments
Labels
Request Request for image modification or feature

Comments

@bgauduch
Copy link

bgauduch commented Nov 15, 2018

Hello 👋

Wouldn't it be better to launch httpd in the container without root, using unix capabilities ?

It could be done this way just before the EXPOSE and COMMAND instructions at the end of the alpine Dockerfile:

# add capacity management library
RUN apk add --no-cache libcap=2.25-r1 && \
  # chown apache working directory
  chown -hR www-data:www-data /usr/local/apache2/ && \
  # Set capability to bind privileged ports as non-root user for httpd
  setcap 'cap_net_bind_service=+ep' /usr/local/apache2/bin/httpd

# use non-root user
USER www-data

Any advice / comment on this ?
Could it break anything downstream ?

Related : issue 102, closed

Good day :-)

@wglambert wglambert added the Request Request for image modification or feature label Nov 15, 2018
@yosifkit
Copy link
Member

setcap will not work with some Docker storage drivers which is why tianon said the following in #102:

Your setcap probably doesn't round-trip through the graph drivers properly.

See also related moby/moby#8460 and especially moby/moby#8460 (comment).

@bgauduch
Copy link
Author

Hello @yosifkit

Thanks for the feedback, so I guess this is the reason why apache start as root before defering to apache user.

In our case I think we will go on with the capability setup if we do not encounter issues with storage driver (deploying on k8s btw).
I believe this question / request can be close then.

Thanks again, good day :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

4 participants