mlcommons / mlcube

MLCube® is a project that reduces friction for machine learning by ensuring that models are easily portable and reproducible.
https://mlcommons.github.io/mlcube/
Apache License 2.0
153 stars 32 forks source link

Docker runs as root (mnist_openfl example) #192

Open msheller opened 3 years ago

msheller commented 3 years ago

When I follow the mnist_openfl example, the container runs as root. This also means that all output files are set to root ownership, and are thus unwriteable by other users.

I modified the example to have separate model_in and model_out directories so that I could overwrite the model_in without being root. here you can see the root ownership:

~/git/mlcube_examples/mnist_openfl/workspace/model_out(master*) » ll
total 4.0K drwxr-xr-x 4 root root 4.0K Jul 13 15:18 mnist_model

tanertopal commented 2 years ago

This is generally an issue with mounted volumes in docker as the docker daemon runs as root. If relative volumes are mounted you need to take care in the docker container how you set the user id and group id.

One approach I have taken in other projects is to pass Linux user and group id (usually $UID/$GID) into the container and write with those ids. That will than have the correct user permissions on the host system which should be desirable for mlcube I think.

This should probably be resolved when the following options --user $(id -u):$(id -g) are added to this string: https://github.com/mlcommons/mlcube/blob/master/runners/mlcube_docker/mlcube_docker/docker_run.py#L85

relja128 commented 2 years ago

We should make this very obvious in the docs so that people don't run into permissions issues.