seafile-containerized/README.md

144 lines
5.8 KiB
Markdown
Raw Normal View History

[![Build Status](https://secure.travis-ci.org/haiwen/seafile-docker.png?branch=master)](http://travis-ci.org/haiwen/seafile-docker)
2015-03-20 16:10:19 +00:00
### About
- [Docker](https://docker.com/) is an open source project to pack, ship and run any Linux application in a lighter weight, faster container than a traditional virtual machine.
- Docker makes it much easier to deploy [a Seafile server](https://github.com/haiwen/seafile) on your servers and keep it updated.
- The base image configures Seafile with the Seafile team's recommended optimal defaults.
2018-04-12 09:27:36 +00:00
If you are not familiar with docker commands, please refer to [docker documentation](https://docs.docker.com/engine/reference/commandline/cli/).
### Getting Started
2018-04-12 09:27:36 +00:00
To run the seafile server container:
2018-04-12 09:27:36 +00:00
```sh
docker run -d --name seafile \
-e SEAFILE_SERVER_HOSTNAME=seafile.example.com \
-v /opt/seafile-data:/shared \
-p 80:80 \
seafileltd/seafile:latest
```
2016-11-26 11:52:07 +00:00
2018-04-12 09:27:36 +00:00
Wait for a few minutes for the first time initialization, then visit `http://seafile.example.com` to open Seafile Web UI.
2016-11-26 11:52:07 +00:00
2018-04-14 03:37:17 +00:00
This command will mount folder `/opt/seafile-data` at the local server to the docker instance. You can find logs and other data under this folder.
2018-04-12 09:27:36 +00:00
### More configuration Options
2016-11-26 11:52:07 +00:00
2018-04-12 09:27:36 +00:00
#### Custom Admin Username and Password
2016-11-29 07:29:36 +00:00
2018-04-12 09:27:36 +00:00
The default admin account is `me@example.com` and the password is `asecret`. You can use a different password by setting the container's environment variables:
e.g.
2016-11-26 11:52:07 +00:00
2018-04-12 09:27:36 +00:00
```sh
docker run -d --name seafile \
-e SEAFILE_SERVER_HOSTNAME=seafile.example.com \
-e SEAFILE_ADMIN_EMAIL=me@example.com \
-e SEAFILE_ADMIN_PASSWORD=a_very_secret_password \
-v /opt/seafile-data:/shared \
-p 80:80 \
seafileltd/seafile:latest
```
If you forget the admin password, you can add a new admin account and then go to the sysadmin panel to reset user password.
#### Let's encrypt SSL certificate
2018-04-12 09:27:36 +00:00
If you set `SEAFILE_SERVER_LETSENCRYPT` to `true`, the container would request a letsencrypt-signed SSL certificate for you automatically.
e.g.
2018-04-12 09:27:36 +00:00
```
docker run -d --name seafile \
-e SEAFILE_SERVER_LETSENCRYPT=true \
-e SEAFILE_SERVER_HOSTNAME=seafile.example.com \
-e SEAFILE_ADMIN_EMAIL=me@example.com \
-e SEAFILE_ADMIN_PASSWORD=a_very_secret_password \
-v /opt/seafile-data:/shared \
-p 80:80 \
-p 443:443 \
seafileltd/seafile:latest
```
If you want to use your own SSL certificate:
2018-04-12 09:27:36 +00:00
- create a folder `/opt/seafile-data/ssl`, and put your certificate and private key under the ssl directory.
- Assume your site name is `seafile.example.com`, then your certificate must have the name `seafile.example.com.crt`, and the private key must have the name `seafile.example.com.key`.
2018-04-12 09:27:36 +00:00
#### Modify Seafile Server Configurations
The config files are under `shared/seafile/conf`. You can modify the configurations according to [Seafile manual](https://manual.seafile.com/)
2018-04-12 09:27:36 +00:00
After modification, you need to restart the container:
```
2018-04-12 09:27:36 +00:00
docker restart seafile
```
#### Find logs
2018-04-14 03:37:17 +00:00
The seafile logs are under `shared/logs/seafile` in the docker, or `/opt/seafile-data/logs/seafile` in the server that run the docker.
2018-04-14 03:37:17 +00:00
The system logs are under `shared/logs/var-log`, or `/opt/seafile-data/logs/var-log` in the server that run the docker.
#### Add a new Admin
2016-11-25 08:18:46 +00:00
2018-04-12 09:27:36 +00:00
Ensure the container is running, then enter this command:
2016-11-25 08:18:46 +00:00
```
2018-04-12 09:27:36 +00:00
docker exec -it seafile /opt/seafile/seafile-server-latest/reset-admin.sh
2016-11-25 08:18:46 +00:00
```
2018-04-12 09:27:36 +00:00
Enter the username and password according to the prompts. You now have a new admin account.
2016-11-25 08:18:46 +00:00
### Directory Structure
2016-11-25 09:09:56 +00:00
#### `/shared`
2016-11-25 09:09:56 +00:00
Placeholder spot for shared volumes. You may elect to store certain persistent information outside of a container, in our case we keep various logfiles and upload directory outside. This allows you to rebuild containers easily without losing important information.
- /shared/db: This is the data directory for mysql server
- /shared/seafile: This is the directory for seafile server configuration and data.
- /shared/logs: This is the directory for logs.
- /shared/logs/var-log: This is the directory that would be mounted as `/var/log` inside the container. For example, you can find the nginx logs in `shared/logs/var-log/nginx/`.
- /shared/logs/seafile: This is the directory that would contain the log files of seafile server processes. For example, you can find seaf-server logs in `shared/logs/seafile/seafile.log`.
- /shared/ssl: This is directory for certificate, which does not exist by default.
### Upgrading Seafile Server
2018-04-12 09:27:36 +00:00
TO upgrade to latest version of seafile server:
```sh
docker pull seafileltd/seafile:latest
docker rm -f seafile
docker run -d --name seafile \
-e SEAFILE_SERVER_LETSENCRYPT=true \
-e SEAFILE_SERVER_HOSTNAME=seafile.example.com \
-e SEAFILE_ADMIN_EMAIL=me@example.com \
-e SEAFILE_ADMIN_PASSWORD=a_very_secret_password \
-v /opt/seafile-data:/shared \
-p 80:80 \
-p 443:443 \
seafileltd/seafile:latest
```
2018-04-12 09:27:36 +00:00
If you are one of the early users who use the `launcher` script, you should refer to [upgrade from old format](https://github.com/haiwen/seafile-docker/upgrade_from_old_format.md) document.
### Garbage Collection
When files are deleted, the blocks comprising those files are marked as unused but not immediately removed. To remove them, Seafile requires a ['garbage collection'](https://manual.seafile.com/maintain/seafile_gc.html) process to be run.
The required scripts can be found in the `/scripts` folder of the docker container. To perform garbage collection, simply run `docker exec seafile /scripts/gc.sh`. For the community edition, this process will stop the seafile server, but it is a relatively quick process and the seafile server will start automatically once the process has finished. The Professional supports an online garbage collection.
### Troubleshooting
2018-04-12 09:27:36 +00:00
You can run docker commands like "docker logs" or "docker exec" to find errors.
2016-11-25 07:10:58 +00:00
2018-04-12 09:27:36 +00:00
```sh
docker logs -f seafile
# or
docker exec -it seafile bash
```