How can I use a NFS share from my TrueNas with Seafile?

Hi

I’m struggling to get Seafile use a NFS share on my TrueNas

What I have done is:

On TrueNas I have created a seafile user, and a dataset, the dataset is owned by the seafile user. Created a NFS share and set the “Mapall user” and “Map all group” to seafile (3005:3005)

then on my docker host I have created a seafile user (3005:3005)I have mounted the share, /mnt/seafile, and verified that it’s permissions is set to seafile:seafileI have then modified the .env so that all volumes is using the new mount pointI have modified the seafile-server.ymlFor the seafile container, I have set the user to 3005:3005, I have modified the port as I have Nginx Reverse Proxy running in may HomeLab, I have disabled SeaDoc.
I the issue docker compose up -d
containers start and say all is good, but loghave this error:

*** Killing all processes…

Traceback (most recent call last):

File “/sbin/my_init”, line 414, in

main(args)

File “/sbin/my_init”, line 330, in main

import_envvars(False, False)

File “/sbin/my_init”, line 90, in import_envvars

for envfile in listdir("/etc/container_environment"):

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/sbin/my_init”, line 74, in listdir

return sorted(os.listdir(path))

              ^^^^^^^^^^^^^^^^

PermissionError: [Errno 13] Permission denied: ‘/etc/container_environment’

What am I missing ?

Kind regards

Steen

Here is a document on how to run Seafile on TrueNAS that a user send me for version 12.0. Hope this can help:

INITIAL DOCKER PULL

Running the YAML file without logging in with credentials and pulling the image will result in credential errors.

CREATING DATASETS

  • The mkdir /opt/seafile/ method does not work on TrueNAS due to write restrictions
  • Created 5 datasets via the webui, 4 for config and 1 for user DATA
  • Final locations:

/mnt/DC600M/CONFIG/Seafile/mariadb
/mnt/DC600M/CONFIG/Seafile/memcached
/mnt/DC600M/CONFIG/Seafile/elasticsearch
/mnt/DC600M/CONFIG/Seafile/seafile
/mnt/DC600M/SEAFILE-SSD-DATA

  • When creating datasets set the type to Apps to allow correct permissions
  • I might be wrong, but I think these config and data locations are not being used, could be wrong.
  • With the initial setup head over to the webui

apps → Discover Apps → Custom App

  • Paste in the YAML file,
  • The MYSQL_ROOT_PASSWORD should match the DB_ROOT_PASSWD in seafile section
  • The MYSQL_PASSWORD should match the DB_PASSWD in seafile section
  • The config datasets are targeted as volumes in the respective services sections of the YAML
  • Port mappings updated to ensure no conflict with TrueNAS ie 80, 443 etc

THE YAML FILE

services:
db:
image: mariadb:10.11
container_name: seafile-mysql
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD=mysql_password
- MYSQL_USER=seafile
- MYSQL_PASSWORD=seafile_db_password
- MYSQL_DATABASE=seafile_db
- MYSQL_LOG_CONSOLE=true
- MARIADB_AUTO_UPGRADE=1
volumes:
- /mnt/DC600_1P75TB/CONFIG/Seafile/mariadb:/var/lib/mysql
networks:
- seafile-net

memcached:
image: memcached:1.6.18
container_name: seafile-memcached
restart: unless-stopped
entrypoint: memcached -m 2048
volumes:
- /mnt/DC600_1P75TB/CONFIG/Seafile/memcached:/data
networks:
- seafile-net

elasticsearch:
image: elasticsearch:8.13.0
container_name: seafile-elasticsearch
restart: unless-stopped
ports:
- “9200:9200”
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- ES_JAVA_OPTS=-Xms2g -Xmx2g
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /mnt/DC600_1P75TB/CONFIG/Seafile/elasticsearch:/usr/share/elasticsearch/data
networks:
- seafile-net

seafile:
image: Harbor
container_name: seafile
restart: unless-stopped
ports:
- “8082:8082”
- “8000:8000”
- “8080:80”
volumes:
- /mnt/DC600_1P75TB/CONFIG/Seafile/seafile:/config
- /mnt/DC600_1P75TB/SEAFILE-SSD-DATA:/seafile-data
environment:
- DB_HOST=db
- DB_ROOT_PASSWD=mysql_password
- DB_NAME=seafile_db_name
- DB_USER=seafile_user_name
- DB_PASSWD=seafile_db_password
- TIME_ZONE=Region/City
- SEAFILE_ADMIN_EMAIL=yourname@yourmailprovider.com
- SEAFILE_ADMIN_PASSWORD=seafile_admin_password
- SEAFILE_SERVER_LETSENCRYPT=false
- SEAFILE_SERVER_HOSTNAME=host_ip_address
depends_on:
- db
- memcached
- elasticsearch
networks:
- seafile-net

networks:
seafile-net:
driver: bridge

POST YAML PROBLEMS

  • Run the script, which is successful, and can login with the seafile client on another machine.
  • Unable to upload, download with the web browser.
  • Able to upload download with the seafile client app

FIXES IN THE MYSQL

  • Needed to login to the mysql db

  • docker exec -it seafile-mysql mysql -uroot -p

  • SELECT user, host FROM mysql.user WHERE user = ‘seafile’;

  • DROP USER ‘seafile’@‘::%’;

  • FLUSH PRIVILEGES;

  • exit

  • restart mysql db

The IPv6 was running but system didn’t support this, may have caused issue as was working afterwards.

UNABLE TO RESTART SEAFILE CONTAINER

  • If the Seafile docker container is stopped and restarted then it is no longer possible to login

  • Requires deletion of the YAML file and datasets to flush all datasets

  • Repeat clean install procedure

  • It may be that a restart of the container is overwriting the initialisation and PW setup since I found that the mysql passwords etc were failing from the log files.

  • I believe the containers were possibly runing under -ix for the volumes but still learning truenas, docker and Seafile setup so not confident to confirm.

  • Portainer is an available app in TrueNAS, was considering to setup the Seafile Pro YAML through the portainer app hopefully giving more flexibility on the setup, restart stop etc which is very limited for custom apps on the truenas webui apps secion.

Thanks for the information.

Not 100% what I am looking for, but I will try.

I do have my containers on a docker-host, I then mount a NFS share - the Share is on my TrueNas, and that is ‘tricky’ part - the issue is “root squash” (I’m not a linux expert, but Google and ChatGPT help)

Hi @rabol,

Don’t hesitate to share your solution for the NFS share, it can always help other users !

Hi

To be honest, I dropped SeaFile after struggling for 3 days t get it working.

(as a small note I create a nextcloud nfs share on the TrueNas server, with the same settings and NextCloud woeks fine)

I have actually also dropped TrueNas as I realised that I only used TrueNas to setup a few shares, zfs snapshots - the backup to my PBS was done via a tool from Proxmox, so not related to TrueNas, so in a few hours I had a new Ubuntu server with a smb share for my Mac back up’s and Windows backups, the photos is handled by Immich running on my docker-host and use nfs share and for files I have a nfs share that Nextcloud is using.

If I understand the ‘problem’ correctly is comes down to “root squashing” of nfs.

I would still love to use SeaFile on my docker host and use a NFS share - it would be too easy just to install it on the new ‘nas’ :slight_smile:

I’ll see if I can get it working and post the result here.

OK, thanks for your reply !

Hello @rabol,

this has nothing to do with seafile itself.

the error ist telling you, that the user seafile on your host has no permission to write to the directory /etc/container_environment

PermissionError: [Errno 13] Permission denied: ‘/etc/container_environment’

I would suggest you the remove the user mapping from the seafile-server.yaml. Add your seafile user on the host to the docker group to get the correct permissions or run the docker compose as superuser by using sudo.

sudo usermod -aG docker seafile
docker compose up -d

or

sudo docker compose up -d

Hope this will help you.

Thanks, I will give it a try

We have tested with NFS share in this week. Here are our findings to the problem:

The Seafile docker image can only be run use root user. Otherwise it will fail to start.

The document on running Seafile as non-root user only set the the seafile process inside the docker to use a non-root user. But the docker image itself must be started as root user. Run Seafile as non root user inside docker - Seafile Admin Manual

To put seafile-data folder on NFS share, the solution is to add “no_root_squash” option when mount the NFS share to the server.