0

I have three different docker containers that have different purposes. They all need to read and write to the same file area.

  • The first container grabs files from the internet and stores them to /storage/prepared folder
  • The second container "listens" to this folder and processes the downloaded files. It then moves them to /storage/finished.
  • The third container runs a web server to let me download these files to my computer as needed.

My current issue came along when I moved my storage from my NAS to some new local storage. The NAS was mounted with cifs and as such everything was read/write (mounted mapped as root@nas, I know, don't mindt that right now...). But now, the first container stores everything as host root:root, and for some reason, the second container has decided that it doesn't want to read anything that is only root access on the host.

Should I create a separate user and use that for the docker containers (how do I do that?). And I also want to have access to the files, but I have my own user, should I make everything group accessible and add myself and the docker user to the same group? (How do I make every new file and folder be group readable and get a certain group ownership when they are created?)

I know enough linux to be dangerous (i.e. the root mount above) but this is more than I know. But I'd like to learn :)

0

You can add users in the container using groupadd/useradd and set set the user for the container:

RUN groupadd -g 2000 appgroup && useradd -g appgroup -u 2000 appuser
USER appuser

When you do so the container runs with the id of the defined user. Outside of rhe container (in bind-mounted directories) files created by code in the container will be owned by the numeric ids you defined with groupadd/useradd. Be careful because the numeric ids are the same inside and outside the container even if they can bear different names.

Of course if several containers run with the same id they should be able to share files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.