-
Notifications
You must be signed in to change notification settings - Fork 103
Allow to run as root / different user #11
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
Comments
The reasoning is security. Root in a container is equal to root on the host. If there was a vulnerability that allowed a breakout from the docker "container" that would give an attacker root access to the host. There is a similar discussion to adding a way to specify the running user for elasticsearch (docker-library/elasticsearch#14). |
Hm, seems partially contradictory: "root in a container is equal to root on the host" and "if there WAS a vulnerability..." ;-) I guess if that vulneratiblity isn't there, it's not at all equal, is it? Anyway, would you be willing to support a RUN_AS_ROOT or RUN_AS env variable for those willing to accept the security risk and opt in to run as root (or another user/group)? |
Isn't the |
"Useless" is a bit far 😉. We use gosu so that we can fix permissions
before we drop privileges, which is impossible with just "-u".
|
Is there currently a workaround or a best practice to actually just read logs on a volume that do not have read permissions set for everybody? If not, I think we definitely need a way to change the user logstash runs with, otherwise we lose the ability to perform a lot of file based use-cases without making changes to permissions on the host which is not really desirable. |
@pazoozooCH, how are file permissions for logstash handled normally outside docker? Does logstash just run as root to see all the logs? And, yes container root does equal host root: |
That is even more awful, btw. |
@yosifkit, in this case, I'd probably add the logstash user to the adm group so it could read the system logs without me having to change default permissions of Ubuntu. In this case, I'd require an option to specify a "run-as group". Well, your example is not really that realistic. Obviously, I wouldn't just mount / into my container and run it as root. I would mount /var/log as readonly into the container and trust docker to actually run it in a container/sandbox that is not escapable... If that actually works (and if it doesn't, Docker would have a BIG problem), I don't see that much of a problem running root INSIDE the container. |
btw, as I've indicated in #10, $HOME for the logstash user currently stays /root, causing problems with Logstash's default settings INSIDE the container. I think the whole user management should be improved on anyway... |
I found a workaround after reading the entrypoint script: give anything other than Run as root:
Run as user
|
Would something like docker-library/elasticsearch#77 be helpful to allow you to specify any non-root user and group to run as, using the |
Hi , how to run , with user logstash , Thanks. |
@EamonZhang, what about the permissions on the directory |
@yosifkit drw-rw-rw- It say no permissions at first, then I change it to drw-rw-rw- with command It does not show permissions problem. but can use , echo "some thing " > /var/log/nginx/access.log . logstash is not responding. I notice docker-entrypoint.sh change the user. I start logstash bypass docker-entrypoint.sh, use root user. It seems ok. |
One side effect of this is that the S3 output plugin will cause the Logstash process to fail to start because during the plugin's registration phase it attempts to write a temporary file to
|
docker run \
-it --rm -v "$PWD":/config-dir \
-v /var/log/apache2/:/var/log/apache2/:ro \
logstash:5 \
- logstash -f /config-dir/logstash.conf according to the 5.0/docker-entrypoint.sh, to run as root: replace line whitch you like + /usr/share/logstash/bin/logstash -f /config-dir/logstash.conf
+ gosu root logstash -f /config-dir/logstash.conf
+ sh -c "logstash -f /config-dir/logstash.conf" |
@pazoozooCH @tianon looks like this could be closed too, right? |
@mi-hol , didn't have time to look at it recently - I guess yes... |
Right now, the easiest way to run as non-root is to use $ docker run --name logstash --user 1000:1000 --entrypoint logstash logstash:5.0 -e '...' |
As noted in #70, I had to also specify |
Is there a compelling reason not to run Logstash in the container as root?
The problem is that the logstash user 999 will not be able to run most logs (like /log/syslog). I think it's better to run root in a Docker container and mount the volume as read-only as to change file permission in the host to allow a non-root docker user to read the logs.
I would suggest just skipping the gosu or add the functionality to specify a user ID to run as when starting the container (through an env variable)...
The text was updated successfully, but these errors were encountered: