I am trying to have files synced between my Nextcloud installed via snap and a docker container with Jupyterlab and I need help because I am completely lost with how to solve .
So, the setup is quite simple: I have a server with Ubuntu and I have installed Nextcloud there via snap. I also have a Jupyterlab server running on the same machine in a docker container. Now, I want to be able to access the same files via both Nextcloud and Jupyterlab (so that I can create Python notebooks both online in Jupyter, but also to be able to easily run and work with them locally via Nextcloud sync if I want more computing power).
What I have done:
- I have created a folder, let’s call it
- I have create a mount point
sudo mount -o bind /home/username/notebooks/ /media/nextcloud
- Enabled external media in snap
sudo snap connect nextcloud:removable-media
- I added a local external storage
- I have my docker container running under
usernameuser (not from root) and mount
/home/username/notebooksas a volume to the docker container.
- I have given the most relaxed possible permissions to the
ls -l in the home directory says that the
notebooks folder permissions are:
drwxrwsrwx 4 username username 4096 notebooks
So far I can successfully see files in both Nextcloud and Jupyter.
However, the problem is that whenever I create any file in Nextcloud, then they are owned by user and group
root:root and have
-rw-r--r-- permissions, and whenever I create any file in Jupyter, they are created with
username:users and have the same
-rw-r--r-- permissions. Therefore, I cannot change in Nextcloud files created by Jupyter and vice-versa.
I am completely lost in the permissions and user systems of docker and snap. How can I fix that and get both of them to collaborate with each other?
Possible solutions I can see:
- Give up and setup a nextcloud client in the docker container with a separate user with whom I only share one folder. I would like to avoid this solution if possible, because there is no headless daemon client for Nextcloud, so I will have to improvise with nextcloudcmd and cron. Also, I think this would waste resources as I will be syncing things via internet within the same server, but I am not 100% sure about that. On the other hand, if there is no other easy solution, then I will go for this one.
- Run docker with Jupyter as root - not sure if it is good from the security point of view, especially given that I am running Jupyter notebooks there which I want to be accessible from the outside. Also, not sure if I can have only one docker container to run from root.
- To somehow make Nextcloud snap work (i.e., create and edit files) from
- To use some Linux magic to get all new files created in this
notebooksdirectory to be writable for the owner group by default and add both users to both groups.
I would be very thankful if someone can at least pinpoint me in the direction of how I can solve my issue, at this point I am not even sure in what technology and direction to look for the solution.