Installation of Seafile Server Community Edition with Docker¶
System requirements¶
Please refer here for system requirements about Seafile CE. In general, we recommend that you have at least 2G RAM and a 2-core CPU (> 2GHz).
Getting started¶
The following assumptions and conventions are used in the rest of this document:
/opt/seafileis the directory for store Seafile docker compose files. If you decide to put Seafile in a different directory — which you can — adjust all paths accordingly.- Seafile uses two Docker volumes for persisting data generated in its database and Seafile Docker container. The volumes' host paths are
/opt/seafile-mysqland/opt/seafile-data, respectively. It is not recommended to change these paths. If you do, account for it when following these instructions. - All configuration and log files for Seafile and the webserver Nginx are stored in the volume of the Seafile container.
Install docker¶
Use the official installation guide for your OS to install Docker.
Download and modify .env¶
To deploy Seafile with Docker, you have to .env, seafile-server.yml and caddy.yml in a directory (e.g., /opt/seafile):
mkdir /opt/seafile
cd /opt/seafile
wget -O .env https://manual.seafile.com/14.0/repo/docker/ce/env
wget https://manual.seafile.com/14.0/repo/docker/ce/seafile-server.yml
wget https://manual.seafile.com/14.0/repo/docker/seadoc.yml
wget https://manual.seafile.com/14.0/repo/docker/caddy.yml
nano .env
Only change the required settings below for a standard deployment. Keep all other values in the template at their defaults unless you need one of the optional configurations described later.
Required settings¶
Easier deployment
For a standard deployment, updating only the settings in this section is sufficient to deploy Seafile.
| Variable | Description | Value |
|---|---|---|
SEAFILE_SERVER_HOSTNAME |
Public hostname or domain of the Seafile server. | Required |
JWT_PRIVATE_KEY |
Random string of at least 32 characters. Generate one with pwgen -s 40 1. |
Required |
SEAFILE_MYSQL_DB_PASSWORD |
Password for the Seafile MySQL user. | Required |
INIT_SEAFILE_MYSQL_ROOT_PASSWORD |
MySQL root password. |
Required on first deployment only |
INIT_SEAFILE_ADMIN_EMAIL |
Initial Seafile administrator username. | Required on first deployment only |
INIT_SEAFILE_ADMIN_PASSWORD |
Initial Seafile administrator password. | Required on first deployment only |
Common optional settings¶
| Variable | Description | Default |
|---|---|---|
BASIC_STORAGE_PATH |
Base directory for Docker persistent data. The derived data, database, and Caddy paths normally do not need to be changed individually. | /opt |
SEAFILE_SERVER_PROTOCOL |
Public server protocol: http or https. |
http |
TIME_ZONE |
Time zone used by the containers. | Etc/UTC |
Database settings¶
| Variable | Description | Default Value |
|---|---|---|
SEAFILE_MYSQL_DB_HOST |
The host of MySQL. | db |
SEAFILE_MYSQL_DB_PORT |
The port of MySQL. | 3306 |
SEAFILE_MYSQL_DB_USER |
The user of MySQL (database - user can be found in conf/seafile.conf). |
seafile |
SEAFILE_MYSQL_DB_PASSWORD is required and listed above. For database names and other database settings, see environment variables.
Cache service settings¶
Seafile Docker uses its integrated Redis service by default, so no cache settings need to be changed for a standard deployment.
| Variable | Description | Default Value |
|---|---|---|
CACHE_PROVIDER |
The type of cache server used by Seafile. Available options are redis and memcached. |
redis |
REDIS_HOST |
The host of Redis. | redis |
REDIS_PORT |
The port of Redis. | 6379 |
REDIS_PASSWORD |
The password of Redis. | (none) |
Recommended Redis since Seafile 13.0
Since Seafile 13.0, many new features depend on Redis as the cache server. Starting with Seafile 14.0, we do not recommend using Memcached as the cache server. If you need to use Memcached, see environment variables for its configuration.
Optional extension settings¶
The template includes settings for optional services such as SeaDoc, the notification server, and metadata server. Leave these disabled unless you are deploying the corresponding service.
WebDAV is built into the Seafile container and can be enabled by setting ENABLE_SEAFDAV=true (and optionally adjusting SEAFDAV_WORKERS); see WebDAV extension.
For a complete list of environment variables, see environment variables.
Start Seafile server¶
Start Seafile server with the following command
docker compose up -d
ERROR: Named volume "xxx" is used in service "xxx" but no declaration was found in the volumes section
You may encounter this problem when your Docker (or docker-compose) version is out of date. You can upgrade or reinstall the Docker service to solve this problem according to the Docker official documentation.
Note
You must run the above command in the directory with the .env. If .env file is elsewhere, please run
docker compose --env-file /path/to/.env up -d
Success
After starting the services, you can see the initialization progress by tracing the logs of container seafile (i.e., docker logs seafile -f)
---------------------------------
This is your configuration
---------------------------------
server name: seafile
server ip/domain: seafile.example.com
seafile data dir: /opt/seafile/seafile-data
fileserver port: 8082
database: create new
ccnet database: ccnet_db
seafile database: seafile_db
seahub database: seahub_db
database user: seafile
Generating seafile configuration ...
done
Generating seahub configuration ...
----------------------------------------
Now creating seafevents database tables ...
----------------------------------------
----------------------------------------
Now creating ccnet database tables ...
----------------------------------------
----------------------------------------
Now creating seafile database tables ...
----------------------------------------
----------------------------------------
Now creating seahub database tables ...
----------------------------------------
creating seafile-server-latest symbolic link ... done
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
And then you can see the following messages which the Seafile server starts successfully:
Starting seafile server, please wait ...
Seafile server started
Done.
Starting seahub at port 8000 ...
----------------------------------------
Successfully created seafile admin
----------------------------------------
Seahub is started
Done.
Finially, you can go to http://seafile.example.com to use Seafile.
Seafile directory structure¶
Path /opt/seafile-data¶
Placeholder spot for shared volumes. You may elect to store certain persistent information outside of a container, in our case we keep various log files and upload directory outside. This allows you to rebuild containers easily without losing important information.
- /opt/seafile-data/seafile: This is the directory for seafile server configuration and data.
- /opt/seafile-data/seafile/logs: This is the directory that would contain the log files of seafile server processes. For example, you can find seaf-server logs in
/opt/seafile-data/seafile/logs/seafile.log.
- /opt/seafile-data/seafile/logs: This is the directory that would contain the log files of seafile server processes. For example, you can find seaf-server logs in
- /opt/seafile-data/logs: This is the directory for operating system.
- /opt/seafile-data/logs/var-log: This is the directory that would be mounted as
/var/loginside the container./opt/seafile-data/logs/var-log/nginxcontains the logs of Nginx in the Seafile container.
- /opt/seafile-data/logs/var-log: This is the directory that would be mounted as
Find logs¶
To monitor container logs (from outside of the container), please use the following commands:
# if the `.env` file is in current directory:
docker compose logs --follow
# if the `.env` file is elsewhere:
docker compose --env-file /path/to/.env logs --follow
# you can also specify container name:
docker compose logs seafile --follow
# or, if the `.env` file is elsewhere:
docker compose --env-file /path/to/.env logs seafile --follow
The Seafile logs are under /shared/logs/seafile in the docker, or /opt/seafile-data/logs/seafile in the server that run the docker.
The system logs are under /shared/logs/var-log, or /opt/seafile-data/logs/var-log in the server that run the docker.
To monitor all Seafile logs simultaneously (from outside of the container), run
sudo tail -f $(find /opt/seafile-data/ -type f -name *.log 2>/dev/null)
More configuration options¶
The config files are under /opt/seafile-data/seafile/conf. You can modify the configurations according to configuration section
Add a new admin¶
Ensure the container is running, then enter this command:
docker exec -it seafile /opt/seafile/seafile-server-latest/reset-admin.sh
Enter the username and password according to the prompts. You now have a new admin account.
Backup and recovery¶
Follow the instructions in Backup and restore for Seafile Docker
Garbage collection¶
When files are deleted, the blocks comprising those files are not immediately removed as there may be other files that reference those blocks (due to the magic of deduplication). To remove them, Seafile requires a 'garbage collection' process to be run, which detects which blocks no longer used and purges them.
FAQ¶
Seafile service and container maintenance¶
Q: If I want enter into the Docker container, which command I can use?
A: You can enter into the docker container using the command:
docker exec -it seafile /bin/bash
Q: I forgot the Seafile admin email address/password, how do I create a new admin account?
A: You can create a new admin account by running
docker exec -it seafile /opt/seafile/seafile-server-latest/reset-admin.sh
The Seafile service must be up when running the superuser command.
Q: If, for whatever reason, the installation fails, how do I to start from a clean slate again?
A: Remove the directories /opt/seafile, /opt/seafile-data and /opt/seafile-mysql and start again.
Q: Something goes wrong during the start of the containers. How can I find out more?
A: You can view the docker logs using this command: docker compose logs -f.
About cache¶
Q: How Seafile use cache?
A: Seafile uses cache to improve performance in many situations. The content includes but is not limited to user session information, avatars, profiles, records from database, etc. From Seafile Docker 13, the Redis takes the default cache server for supporting the new features (please refer the upgradte notes), which has integrated in Seafile Docker 13 and can be configured directly in environment variables in .env (no additional settings are required by default)
Q: Is the Redis integrated in Seafile Docker safe? Does it have an access password?
A: Although the Redis integrated by Seafile Docker does not have a password set by default, it can only be accessed through the Docker private network and will not expose the service port externally. Of course, you can also set a password for it if necessary. You can set REDIS_PASSWORD in .env and remove the following comment markers in seafile-server.yml to set the integrated Redis' password:
services:
...
redis:
image: ${SEAFILE_REDIS_IMAGE:-redis}
container_name: seafile-redis
# remove the following comment markers
command:
- /bin/sh
- -c
- redis-server --requirepass "$${REDIS_PASSWORD:?Variable is not set or empty}"
networks:
- seafile-net
...