-
Notifications
You must be signed in to change notification settings - Fork 3
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
Run server entrypoint as non-root #376
Conversation
I tested this locally and the server cannot write to the specified data folders due to filesystem rights. I found the following structure after executing docker@a68a8a1ec0dd:/$ ls -alR /mnt
/mnt:
total 12
drwxr-xr-x 1 root root 4096 Mar 22 00:11 .
drwxr-xr-x 1 root root 4096 Mar 22 00:09 ..
drwxr-xr-x 2 root root 4096 Mar 21 23:24 seerep-data
/mnt/seerep-data:
total 8
drwxr-xr-x 2 root root 4096 Mar 21 23:24 .
drwxr-xr-x 1 root root 4096 Mar 22 00:11 ..
-rw-r--r-- 1 root root 0 Mar 21 23:24 logseerep_0.log Another thing I noticed at seerep/docker/docker-compose.yml Line 16 in a2d087b
/ in the path of the SEEREP_DATA_FOLDER could be removed, because the server prints the path as /mnt/seerep-data//4b51b965-62b1-4b23-8bf0-180b7bb0159c.h5 .This just seems to be a cosmetic thing, but would fit in this pr in my opinion. |
How did you start the server? The volumes section in the docker compose is quite nuanced. The default config uses a named volume, if the mount location does not exist ( However, the comment in: seerep/docker/docker-compose.yml Line 13 in a7b33c5
states to use a bind mount by providing an absolute path on the host. The permissions are then determined by the permission of the directory. Surprisingly, if the directory on the host does not exist, it will also get created, owned by root. I totally agree that this default behavior is confusing. I have to think about which volume type makes the most sense for our use case as a named volume is more portable, but with bind mounts we could easily sync HDF5 files to a server directory e.g using |
I started the server using the As far as I know Edit: |
Yes, that should generally resolve the problem, however with this approach we would hard code the mount location in the Dockerfile. As a result, we would always have to rebuild the image when the path changes. I'm not sure if this will ever happen, but if it is possible to change the ownership in the |
I added this, before switching the user: RUN mkdir -p /mnt/seerep_data && chown docker:docker /mnt/seerep_data Resulting in:
Did you delete the old volume? |
Yes, but I set the rights just to the |
Something like this could work docker/compose#3270 (comment), but it also feels clunky. |
Yeah, this would put the the path configuration for the volume in one place. Additionally environment variables could be used to keep the configuration for the paths in one place. But spinning up another container for that task seems unnecessary. Maybe something like a |
That should work, however if we build the server image in the CI and push it into a registry the path is already pre-determined since it has to be known at build time. |
As our concern is usability and not security right now, we can use this approach. We should also add an env var in the docker-compose to set the user so that the user in the container and the user of the host can match. The path within the docker container can be hardcoded. The is no reason why a user would change it. |
a7b33c5
to
ed6071a
Compare
We once had the idea of using network storage, I thought it could be useful for that. I now used the approach with a second service for changing the permission. The |
Is there a reason to seperate |
additionally this allows to specify the data and log directories in an env file
ed6071a
to
0fb83ee
Compare
Good catch, I forgot to change it back after testing some things. |
Closes #375