好的,我帮你整理一份使用 Docker 部署 Seafile V12.0 的完整教程,包括数据库、Docker Compose 配置和启动步骤。


一、准备工作

  1. 服务器环境
    • 操作系统:Linux(Ubuntu 20.04 或 CentOS 7/8 推荐)
    • Docker:安装最新版 Docker
    • Docker Compose:安装最新版 Docker Compose
    • 推荐至少 2GB 内存,50GB 硬盘
  2. 端口规划
    • Seafile Web: 80 或 443(HTTPS)
    • 数据库 MySQL/MariaDB: 3306
    • 文件存储挂载目录:持久化数据
  3. 安装 Docker 和 Docker Compose
# 安装 Docker
curl -fsSL https://get.docker.com | bash
sudo systemctl enable docker
sudo systemctl start docker

# 安装 Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version


二、创建目录结构

mkdir -p ~/seafile-docker/{seafile-data,db-data,nginx}
cd ~/seafile-docker

  • seafile-data:Seafile 服务数据持久化
  • db-data:MySQL/MariaDB 数据持久化
  • nginx:反向代理(可选 HTTPS)

三、Docker Compose 配置

创建 docker-compose.yml

version: '2.0'

services:
  db:
    image: mariadb:10.5
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=seafile_root_password
      - MYSQL_DATABASE=seafile_db
      - MYSQL_USER=seafile_user
      - MYSQL_PASSWORD=seafile_password
    volumes:
      - ./db-data:/var/lib/mysql
    restart: always

  memcached:
    image: memcached:1.5.22
    container_name: seafile-memcached
    restart: always

  seafile:
    image: seafileltd/seafile-mc:12.0.0
    container_name: seafile
    ports:
      - "8082:80"          # Web 管理端口
      - "8080:8000"        # API / Web 前端端口
      - "5222:5222"        # 文件传输服务(可选)
    depends_on:
      - db
      - memcached
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=seafile_root_password
      - SEAFILE_ADMIN_EMAIL=admin@example.com
      - SEAFILE_ADMIN_PASSWORD=admin_password
      - SEAFILE_SERVER_HOSTNAME=seafile.example.com
    volumes:
      - ./seafile-data:/shared
    restart: always

⚠️ 替换密码和邮箱为实际值。SEAFILE_SERVER_HOSTNAME 填写你的域名或服务器 IP。


四、启动 Seafile

docker-compose up -d

  • 查看容器状态:
docker-compose ps

  • 查看日志:
docker-compose logs -f seafile


五、访问 Seafile

  1. 打开浏览器访问: http://服务器IP:8082
  2. 使用 SEAFILE_ADMIN_EMAILSEAFILE_ADMIN_PASSWORD 登录。
  3. 可在管理后台创建用户、库和团队。

六、可选:配置 HTTPS 反向代理(Nginx)

  1. nginx 目录创建配置文件:
server {
    listen 80;
    server_name seafile.example.com;

    location / {
        proxy_pass http://seafile:80;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

  1. 启动 Nginx:
docker run -d --name seafile-nginx \
  -p 80:80 \
  -v $(pwd)/nginx:/etc/nginx/conf.d \
  --link seafile:seafile \
  nginx

  1. 配置证书(Let’s Encrypt / 自签证书)启用 HTTPS。

七、常用管理命令

# 查看容器
docker ps

# 查看日志
docker logs -f seafile

# 重启服务
docker-compose restart

# 停止服务
docker-compose down