Allowing a remote docker container to change ownship of files/folders in FreeNAS?

Lighthouse

Dabbler
Joined
Nov 15, 2018
Messages
15
So, the setup is I have two separate machines, one obviously FreeNAS and other is Ubuntu Server with docker containers.

Using NFS, I mounted a dataset from FreeNAS to my docker server, and bound the folders to containers so that any persistent data should be stored to FreeNAS instead of local machine.

Now, this works for some containers but the problem begins with database. I have two MariaDB Servers as containers and they simply do not like to use remote mount from FreeNAS because it seems they are trying to change ownership of files and folders, fail to do so then stop. I kind of understand the 'user' of docker container is different from the 'user' of the Ubuntu Server itself but I just can't solve this problem.

I tried to mount via cifs instead of nfs, but then all containers are unable to read/write the mounted dataset at all.

Is there any good solution to this?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Stay with NFS, mark the directory as 777 in FreeNAS first, then run docker... take console of the docker and do chmod from in there.
 

Lighthouse

Dabbler
Joined
Nov 15, 2018
Messages
15
Stay with NFS, mark the directory as 777 in FreeNAS first, then run docker... take console of the docker and do chmod from in there.

I did it, but the issue is that it is the container itself changing the ownership properties of the files, and then it stops working when it finds out it cannot do that. I already did 777 on all files but it seems it really does not matter at all.
 

anmnz

Patron
Joined
Feb 17, 2018
Messages
286
I've come across some Docker images that behave this way. Setting the "maproot user" on the share to "root" seems to let them do what they are trying to do (I also set "maproot group" to wheel).

I've only done this in a private experimental setting, not going to comment about the security implications...
 

Lighthouse

Dabbler
Joined
Nov 15, 2018
Messages
15
I've come across some Docker images that behave this way. Setting the "maproot user" on the share to "root" seems to let them do what they are trying to do (I also set "maproot group" to wheel).

I've only done this in a private experimental setting, not going to comment about the security implications...

Well.. it is rather risky, but at least my stuffs are never going to be exposed to public, either internal LAN or VPN. See how that would solve the issue...
 

Lighthouse

Dabbler
Joined
Nov 15, 2018
Messages
15
Welp, setting maproot privileges solved the problem. Thank you for the suggestion, anmnz.
 
Top