keep-core icon indicating copy to clipboard operation
keep-core copied to clipboard

Run the container as a user without privileges

Open alphastorm opened this issue 5 years ago • 2 comments

Currently the client runs as root by default:

user@host:~/keep-core$ sudo docker run --entrypoint "" keepnetwork/keep-client:latest whoami
root

Per https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user it's better to run as a non-root user when possible. This copies the approach from https://github.com/prometheus/prometheus/pull/2859, which defaults to using nobody and allows overrides using the --user flag (for more discussion see https://github.com/prometheus/prometheus/issues/3441).

After the change:

user@host:~/keep-core$ sudo docker run --entrypoint "" keep-client-nobody:latest whoami
nobody

Tested by building the image from source and running my testnet node with it and the --user $UID:$GID flag (node was originally setup using these instructions).

NOTE: This is a breaking change and after landing users will need to ensure the mounted persistent directory has the correct ownership and/or they set --user correctly.

alphastorm avatar May 24 '20 18:05 alphastorm

@nkuba thoughts on this?

mhluongo avatar Jul 31 '20 14:07 mhluongo

I'm OK with the change but I'd like to confirm it won't break our test environments first.

EDIT: Actually there's a high probability this will break our envs. We need to reflect this change in env configurations and merge it once the environment is ready to handle it.

nkuba avatar Jul 31 '20 15:07 nkuba