Seafile 服务端安装

Seafile 作为个人开源网盘服务有一个自动备份历史修改的功能,已经基本足够了。而且几乎所有客户端也都有,分享和权限管理也做的刚好足够。但是其安装方式从原来的 GitHub 脚本一键安装,到后续的各种老的 Docker 安装,以及目前官网主页最新的 Docker 安装方式,变化较大,这里记录实际安装的环境版本以及安装好后与 Nginx 冲突的问题。

系统版本选择

我这里选择的是 Ubuntu 20.04 版本.

Docker 安装

不能用 snap 安装,都否会出现类似如下没有权限新建文件夹的错误:

ERROR: for worker-1 Cannot start service worker-1: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system

用官方的 apt-get 安装:

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

常用命令

查看 Docker 版本和详细信息
docker info
查看正在运行的容器
docker ps
列出所有容器,包括已停止的容器:
docker ps -a
删除引用该镜像的容器:
docker rm <CONTAINER ID>
列出所有安装的镜像
docker images
强制删除镜像
docker rmi -f <IMAGE ID>

Seafile 安装

下载 docker-compose.yml 文件,我这里选择的是 11.0 CE 社区版本,并修改管理员账号(SEAFILE_ADMIN_EMAIL),密码(SEAFILE_ADMIN_PASSWORD)以及服务器地址(SEAFILE_SERVER_HOSTNAME)。

services:
  db:
    image: mariadb:10.11
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
      - MARIADB_AUTO_UPGRADE=1
    volumes:
      - /opt/seafile-mysql/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.6.18
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
          
  seafile:
    image: seafileltd/seafile-mc:11.0-latest
    container_name: seafile
    ports:
      - "80:80"
#      - "443:443"  # If https is enabled, cancel the comment.
    volumes:
      - /opt/seafile-data:/shared   # Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev  # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=xxx@163.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=xxx     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether use letsencrypt to generate cert.
      - SEAFILE_SERVER_HOSTNAME=161.xx.xxx.xx # Specifies your host name.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:

然后,执行 docker compose up -d 命令即可。进入 Seafile 页面用 docker-compose.yml 设置的管理员账号密码登陆即可。

注:如果有碰到 80 端口倍 Nginx 占用,表现为打开服务器地址显示 Nginx 页面,则通过 sudo systemctl stop nginx 将这个服务停止,然后再执行 docker 运行命令即可。完整过程如下所示:

root@MicroFB:~# docker compose up -d
[+] Running 0/3
[+] Running 33/33                                                                                                                                            0.3s 
 ✔ db Pulled                                                                                                                                                27.7s 
   ✔ 3713021b0277 Pull complete                                                                                                                             10.5s 
   ✔ b7ed4502c671 Pull complete                                                                                                                             10.6s 
   ✔ ccee233ae035 Pull complete                                                                                                                             12.5s 
   ✔ 0c8d32e87829 Pull complete                                                                                                                             12.6s 
   ✔ 257a4184da5c Pull complete                                                                                                                             12.7s 
   ✔ 079eb852aa15 Pull complete                                                                                                                             26.3s 
   ✔ c6b6414a516a Pull complete                                                                                                                             26.4s 
   ✔ 96faa6efb673 Pull complete                                                                                                                             26.4s 
 ✔ memcached Pulled                                                                                                                                         18.2s 
   ✔ 3f9582a2cbe7 Pull complete                                                                                                                             16.0s 
   ✔ 2b4a13da561f Pull complete                                                                                                                             16.2s 
   ✔ 98ecfc959437 Pull complete                                                                                                                             16.4s 
   ✔ 03ca80a0778b Pull complete                                                                                                                             16.8s 
   ✔ 143814477eae Pull complete                                                                                                                             16.8s 
   ✔ 3c2bc07c763e Pull complete                                                                                                                             16.8s 
 ✔ seafile Pulled                                                                                                                                           56.5s 
   ✔ 3dd181f9be59 Pull complete                                                                                                                             12.6s 
   ✔ d700e64e05a2 Pull complete                                                                                                                             12.7s 
   ✔ c378ae4eca3c Pull complete                                                                                                                             22.7s 
   ✔ ebd7cb07e8d9 Pull complete                                                                                                                             22.8s 
   ✔ 673ebd0b2c79 Pull complete                                                                                                                             27.3s 
   ✔ 8f3a871686f0 Pull complete                                                                                                                             30.1s 
   ✔ 491259946e61 Pull complete                                                                                                                             32.3s 
   ✔ e6b2a7810eae Pull complete                                                                                                                             38.3s 
   ✔ b733a29f4802 Pull complete                                                                                                                             49.2s 
   ✔ 4260865b66b4 Pull complete                                                                                                                             49.3s 
   ✔ 74053ed00b75 Pull complete                                                                                                                             49.3s 
   ✔ 643b124b9da1 Pull complete                                                                                                                             49.3s 
   ✔ eca46377af8e Pull complete                                                                                                                             49.5s 
   ✔ 47c599991f4c Pull complete                                                                                                                             49.5s 
   ✔ 1ae61a16c5a1 Pull complete                                                                                                                             49.5s 
   ✔ 8fa7edb38442 Pull complete                                                                                                                             55.2s 
[+] Running 3/4
 ✔ Network root_seafile-net     Created                                                                                                                      0.1s 
 ✔ Container seafile-memcached  Started                                                                                                                      1.5s 
 ✔ Container seafile-mysql      Started                                                                                                                      1.5s 
 ⠴ Container seafile            Starting                                                                                                                     1.5s 
Error response from daemon: driver failed programming external connectivity on endpoint seafile (cb5121ad6d6fc6b826f87d668f8b3f960d15a017e8788637b6ecea6c050320f0): failed to bind port 0.0.0.0:80/tcp: Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
root@MicroFB:~# 
root@MicroFB:~# docker images
REPOSITORY              TAG           IMAGE ID       CREATED         SIZE
seafileltd/seafile-mc   11.0-latest   f513b59a77cd   2 hours ago     1.39GB
mariadb                 10.11         fccf0a9f80df   8 weeks ago     404MB
memcached               1.6.18        0730201b15c1   17 months ago   89.3MB
root@MicroFB:~# sudo lsof -i :80
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   20048     root    6u  IPv4  79714      0t0  TCP *:http (LISTEN)
nginx   20048     root    7u  IPv6  79715      0t0  TCP *:http (LISTEN)
nginx   20049 www-data    3u  IPv4  79992      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:60852 (ESTABLISHED)
nginx   20049 www-data    6u  IPv4  79714      0t0  TCP *:http (LISTEN)
nginx   20049 www-data    7u  IPv6  79715      0t0  TCP *:http (LISTEN)
nginx   20049 www-data   11u  IPv4  80202      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:15291 (ESTABLISHED)
nginx   20049 www-data   12u  IPv4  80203      0t0  TCP MicroFB:http->178.157.57.117.16clouds.com:51641 (ESTABLISHED)
nginx   20049 www-data   13u  IPv4  80252      0t0  TCP MicroFB:http->175.152.79.16:10373 (ESTABLISHED)
nginx   20049 www-data   14u  IPv4  81189      0t0  TCP MicroFB:http->178.157.57.117.16clouds.com:51642 (ESTABLISHED)
nginx   20049 www-data   15u  IPv4  82164      0t0  TCP MicroFB:http->175.152.79.16:10374 (ESTABLISHED)
nginx   20049 www-data   16u  IPv4  91290      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:61131 (ESTABLISHED)
nginx   20049 www-data   17u  IPv4  84293      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:15317 (ESTABLISHED)
nginx   20049 www-data   18u  IPv4  84993      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:60872 (ESTABLISHED)
nginx   20049 www-data   19u  IPv4  84994      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:60870 (ESTABLISHED)
nginx   20049 www-data   20u  IPv4  84995      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:60871 (ESTABLISHED)
nginx   20049 www-data   21u  IPv4  84997      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:60873 (ESTABLISHED)
nginx   20049 www-data   22u  IPv4  95716      0t0  TCP MicroFB:http->23.106.143.212.16clouds.com:15956 (ESTABLISHED)
root@MicroFB:~# sudo systemctl stop nginx
root@MicroFB:~# sudo netstat -tuln | grep :80
sudo: netstat: command not found
root@MicroFB:~# apt-get install netstat
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package netstat
root@MicroFB:~# docker images
REPOSITORY              TAG           IMAGE ID       CREATED         SIZE
seafileltd/seafile-mc   11.0-latest   f513b59a77cd   2 hours ago     1.39GB
mariadb                 10.11         fccf0a9f80df   8 weeks ago     404MB
memcached               1.6.18        0730201b15c1   17 months ago   89.3MB
root@MicroFB:~# docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED         STATUS         PORTS       NAMES
503a0522b070   memcached:1.6.18   "memcached -m 256"       2 minutes ago   Up 2 minutes   11211/tcp   seafile-memcached
e86086fd9f89   mariadb:10.11      "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes   3306/tcp    seafile-mysql
root@MicroFB:~# docker-compose up -d

Command 'docker-compose' not found, but can be installed with:

snap install docker          # version 24.0.5, or
apt  install docker-compose  # version 1.25.0-1

See 'snap info docker' for additional versions.

root@MicroFB:~# docker compose up -d
[+] Running 3/3
 ✔ Container seafile-memcached  Running                                                                                                                      0.0s 
 ✔ Container seafile-mysql      Running                                                                                                                      0.0s 
 ✔ Container seafile            Started                                                                                                                      0.7s 
root@MicroFB:~# 
root@MicroFB:~# 
root@MicroFB:~# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED         STATUS          PORTS                               NAMES
de29eaa96e6d   seafileltd/seafile-mc:11.0-latest   "/sbin/my_init -- /s…"   3 minutes ago   Up 13 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   seafile
503a0522b070   memcached:1.6.18                    "memcached -m 256"       3 minutes ago   Up 3 minutes    11211/tcp                           seafile-memcached
e86086fd9f89   mariadb:10.11                       "docker-entrypoint.s…"   3 minutes ago   Up 3 minutes    3306/tcp                            seafile-mysql
root@MicroFB:~# docker ps
CONTAINER ID   IMAGE                               COMMAND                  CREATED         STATUS          PORTS                               NAMES
de29eaa96e6d   seafileltd/seafile-mc:11.0-latest   "/sbin/my_init -- /s…"   3 minutes ago   Up 21 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   seafile
503a0522b070   memcached:1.6.18                    "memcached -m 256"       3 minutes ago   Up 3 minutes    11211/tcp                           seafile-memcached
e86086fd9f89   mariadb:10.11                       "docker-entrypoint.s…"   3 minutes ago   Up 3 minutes    3306/tcp                            seafile-mysql

参考资料

  • https://cloud.seafile.com/published/seafile-manual-cn/docker/%E7%94%A8Docker%E9%83%A8%E7%BD%B2Seafile.md