docker: run in front-envoy container as root#12112
docker: run in front-envoy container as root#12112akonradi wants to merge 1 commit intoenvoyproxy:masterfrom
Conversation
If run as the 'envoy' user, the proxy can't read the config yaml file and fails to start up. Also change the docker-compose version to 3.3 because none of the later features are being used. Signed-off-by: Alex Konradi <akonradi@google.com>
|
cc. @phlax |
|
i think we dont want to run as root - rather ensure the i didnt test all the examples, but i can take a look and PR to fix this in this case. ill check the other examples at the same time to see if there is any other problems. |
|
This is definitely a permissions issue at heart. I was able to work around it by giving world read permissions to |
|
@akonradi git does have permission for the repo and the file is setting right at It is more likely your environment specific issue, (perhaps |
| - "8443:8443" | ||
| - "8001:8001" | ||
| environment: | ||
| - ENVOY_UID=0 |
There was a problem hiding this comment.
| - ENVOY_UID=0 | |
| - ENVOY_UID |
we can do this so it propagates from your local env, while the default is still non-root?
|
@lizan if the problem is with the environment rather than the example, then changing the example here won't help with other examples or running (with this problem) more generally im wondering if we should add something to the running with docker docs along the lines of The If you are running in an environment with a strict |
|
also, if you want to give the process inside the container permission to file/s without changing permissions on the file/s, the better pattern is to make the ie - good pattern this also works with this would also work with |
|
I added a PR with some docs on configuration file permissions |
|
Thanks, that's a good clarification for the docs. I still want to try to make the example work as-is, with just docker-compose. I don't know that running as root in the container is the right solution, but I think that targeting "git clone [...]; cd [...]; docker-compose [...]" as the steps required to play around is the goal we should be aiming for. |
|
@akonradi its a pretty rare situation to have strict umask like that in a dev env (imhe) the above fix with personally i think using the ...but in the vast majority of cases would not be necessary |
|
I can't speak to the rarity of having world read permissions on dev files. I don't understand why running Envoy as root in the container for the purposes of the example is bad. The rationale in #11311 is that it's a better security practice to run as a non-root user, and I think that's true and that the ability to set the UID is a useful knob to have. That being said, the binary is running in a container and Docker prevents it binding new ports, or writing files to the host since the only attached volume is the config file. |
yep, i started thinking of some counter-examples. i think the point remains that most people would not face this issue
i think because its an example - and the example should exemplify good practice - running as root in containers is not good practice, i think. this point has been underlined by the suggestions to restore the old behaviour - ie root in container - over using the host user perms (who has docker perms anyway so the point is a little moot) or setting file permissions correctly
the main risk is that an admin mounts something that exposes the host security - eg |
Add further info on file permissions to Docker docs. See #12112 Risk Level: very low Testing: n/a Docs Changes: yes Release Notes: n/a Signed-off-by: Ryan Northey <ryan@synca.io>
|
We could write a bash script to set to docker-compose.yaml as @lizan suggested. The script could also accept an option to add/remove the p.s I am a newbie, so I could be wrong. |
|
Another solution that comes to mind (again not sure if is good enough), we could just copy the config file and give ownership of the new file to the In docker-compose.yaml -> remove the mounted volume. I tested this and it runs perfectly. Not sure if copying is a "best practice" here tho. |
I think this is a good idea if we want the examples to work out of the box without needing to add any Looking through the examples it seems like most of them would need updating in this way. Im also noticing that in the existing recipes there are already some files that are copied in eg here: These may need their permissions changing too My only niggling concern - which i dont think would break the examples as documented - is that if a user did set the One possible solution is to make the file world readable within the container - ie |
|
i created a test repo to run through the commands in the docs against the recipes in the examples. so far i have managed to reproduce @akonradi 's error - as can be seen here: https://travis-ci.org/github/phlax/envoy-examples/builds/710765435#L838 i'll create a PR with the variant suggested to @yosrym93 's fix , and add the other examples to the test runner |
|
@phlax I tried making the file readable in the container by running |
|
@yosrym93 the file gets mounted as a volume when the container runs. We could bake it into the image like you suggested (the |
|
@akonradi These config files are meant to be static, and (I think) envoy only reads the config once when it runs. So if the user changes the config they have to re-run the container anyway. Rebuilding won't take anytime because everything is cached and this is the final layer, it'll just re-copy the file. |
|
Yep, there's no watching of the config or anything after startup. That seems like a workable solution for this example if we're okay with having people run |
|
@akonradi @yosrym93 i am going through and testing the examples with the fix suggested. there are quite a few other failures - some eg trying to log to its going to take some time to go through and test/fix each one, but i should have a PR with all examples working by tomorrow for info the latest passing build is here https://travis-ci.org/github/phlax/envoy-examples/builds/710840148 and failing here: https://travis-ci.org/github/phlax/envoy-examples/builds/710826221 re rebuilding - i would agree - its trivial to rebuild. |
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Add further info on file permissions to Docker docs. See envoyproxy#12112 Risk Level: very low Testing: n/a Docs Changes: yes Release Notes: n/a Signed-off-by: Ryan Northey <ryan@synca.io> Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
Add further info on file permissions to Docker docs. See envoyproxy#12112 Risk Level: very low Testing: n/a Docs Changes: yes Release Notes: n/a Signed-off-by: Ryan Northey <ryan@synca.io> Signed-off-by: scheler <santosh.cheler@appdynamics.com>
|
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
If run as the 'envoy' user, the proxy can't read the config yaml file and fails to start up. The not-starting-up appears to be a side-effect of #11323.
Also change the docker-compose version to 3.3 because none of the newer features are being used.
Signed-off-by: Alex Konradi akonradi@google.com
Commit Message: Run proxy as root in front-envoy container
Additional Description:
If run as the 'envoy' user, the proxy can't read the config yaml file and fails to start up.
Risk Level: low
Testing: ran
docker-compose upand saw proxy and services were runningDocs Changes: none
Release Notes: none
@yosrym93