使用Docker 部署Seafile V12.0

本文档使用以下约定:
  • /opt/seafile是存储Seafile docker compose文件的目录。如果您将Seafile放在不同的目录中,请相应地调整所有路径。
  • Seafile 使用两个 Docker 卷 来保存其数据库和 Seafile Docker 容器中生成的数据。卷的主机路径分别是/opt/seafile-mysql/opt/seafile-data,不建议更改这些路径。 如果您修改了路径,请在按照这些说明进行操作时考虑到这一点。
  • Seafile 和 Nginx 的所有配置和日志文件都存储在 Seafile 容器的卷中。
下载并修改 .env
从 Seafile Docker 12.0开始,我们使用以下四个配置文件:.envseafile-server.yml caddy.ymlseadoc.yml
mkdir /data/seafile
cd /data/seafile


# Seafile CE 12.0
wget -O .env https://manual.seafile.com/12.0/repo/docker/ce/env
wget https://manual.seafile.com/12.0/repo/docker/ce/seafile-server.yml
wget https://manual.seafile.com/12.0/repo/docker/caddy.yml
wget https://manual.seafile.com/12.0/repo/docker/seadoc.yml


vim .env

.env内部的变量解释

先用pwgen生成JWT私匙

apt install pwgen
pwgen -s 40 1
2zf7FwjCxGcOAN1erYVTTWM2gousCMsZdv3enAqx

修改.env全局变量:vim .env

COMPOSE_FILE='seafile-server.yml,caddy.yml,seadoc.yml'
COMPOSE_PATH_SEPARATOR=','


SEAFILE_IMAGE=seafileltd/seafile-mc:12.0-latest
SEAFILE_DB_IMAGE=mariadb:10.11
SEAFILE_MEMCACHED_IMAGE=memcached:1.6.29
SEAFILE_CADDY_IMAGE=lucaslorentz/caddy-docker-proxy:2.9-alpine

SEAFILE_VOLUME=/data/seafile-data
SEAFILE_MYSQL_VOLUME=/data/seafile-mysql/db
SEAFILE_CADDY_VOLUME=/data/seafile-caddy

SEAFILE_MYSQL_DB_HOST=db
INIT_SEAFILE_MYSQL_ROOT_PASSWORD=Ew5r********f1CYz
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=Ew5rP******h2f1CYz

TIME_ZONE=Asia/Shanghai

JWT_PRIVATE_KEY=2zf7FwjCxGcOAN1erYVTTWM2gousCMsZdv3enAqx

SEAFILE_SERVER_HOSTNAME=10.XX.XX.102
SEAFILE_SERVER_PROTOCOL=http

INIT_SEAFILE_ADMIN_EMAIL=admin@xxx.work
INIT_SEAFILE_ADMIN_PASSWORD=se7sw@6N~nlCaN


SEADOC_IMAGE=seafileltd/sdoc-server:1.0-latest
SEADOC_VOLUME=/data/seadoc-data

ENABLE_SEADOC=true


NOTIFICATION_SERVER_IMAGE=seafileltd/notification-server:12.0-latest
NOTIFICATION_SERVER_VOLUME=/data/notification-data

注意,有些特殊符号,需要引号引起来,所以除了管理员密码INIT_SEAFILE_ADMIN_PASSWORD=se7sw@6N~nlCaN,尽量不要用特殊符号

 

PS:由于我修改了默认路径/opt/data,所以所有配置文件都需要修改

 依次修改配置文件

vim caddy.yml
vim seadoc.yml
vim seafile-server.yml

docker images#查看本地镜像仓库镜像文件

[root@seafile-server-opts seafile]# docker images
REPOSITORY                        TAG           IMAGE ID       CREATED        SIZE
hello-world                       latest        74cc54e27dc4   3 weeks ago    10.1kB
seafileltd/sdoc-server            1.0-latest    26891cd42918   5 weeks ago    1.16GB
seafileltd/seafile-mc             12.0-latest   215029a12645   5 weeks ago    1.46GB
seafileltd/notification-server    12.0-latest   d07cc70df0ce   8 weeks ago    87.7MB
mariadb                           10.11         73b895f9f0fd   3 months ago   326MB
memcached                         1.6.29        86ca8da22bc4   7 months ago   84.8MB
lucaslorentz/caddy-docker-proxy   2.9-alpine    af05b412c6c0   8 months ago   51.5MB
[root@seafile-server-opts seafile]#

docker ps #查看端口映射

[root@seafile-server-opts seafile]# docker ps
CONTAINER ID   IMAGE                                        COMMAND                  CREATED         STATUS                   PORTS                                                               NAMES
52bec3ed04d4   seafileltd/seafile-mc:12.0-latest            "/sbin/my_init -- /s…"   2 minutes ago   Up About a minute        80/tcp                                                               seafile
98ced4dcdfd3   mariadb:10.11                                "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes (healthy)   3306/tcp                                                               seafile-mysql
0e48b39f21b7   memcached:1.6.29                             "memcached -m 256"       2 minutes ago   Up 2 minutes             11211/tcp                                                               seafile-memcached
aab4a71b5b1a   lucaslorentz/caddy-docker-proxy:2.9-alpine   "/bin/caddy docker-p…"   2 minutes ago   Up 2 minutes (healthy)   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 2019/tcp   seafile-caddy
[root@seafile-server-opts seafile]#

  

 查看Docker Compose版本  docker-compose -v

[root@seafile-server-opts seafile]# docker-compose -v
Docker Compose version v2.30.3
[root@seafile-server-opts seafile]#

拉取镜像会出现网络不通的现象,这就需要将镜像单独导入 docker load -i命令

[root@seafile-server-opts images]# ls
caddy.tar  notification-server.tar.gz  sdoc-server-1.0-latest.tar  seafile-mc.tar
[root@seafile-server-opts images]#docker load -i caddy.tar
[root@seafile-server-opts images]#docker load -i notification-server.tar.gz
[root@seafile-server-opts images]#docker load -i sdoc-server-1.0-latest.tar
[root@seafile-server-opts images]#docker load -i seafile-mc.tar
[root@seafile-server-opts images]# docker images
REPOSITORY                        TAG           IMAGE ID       CREATED        SIZE
hello-world                       latest        74cc54e27dc4   2 days ago     10.1kB
seafileltd/sdoc-server            1.0-latest    26891cd42918   2 weeks ago    1.16GB
seafileltd/seafile-mc             12.0-latest   215029a12645   2 weeks ago    1.46GB
seafileltd/notification-server    12.0-latest   d07cc70df0ce   5 weeks ago    87.7MB
mariadb                           10.11         73b895f9f0fd   2 months ago   326MB
memcached                         1.6.29        86ca8da22bc4   6 months ago   84.8MB
lucaslorentz/caddy-docker-proxy   2.9-alpine    af05b412c6c0   7 months ago   51.5MB
[root@seafile-server-opts seafile]#

删除测试镜像 IMAGE :hello-world,这里可以直接用CONTAINER ID删除,命令是docker rm 0940a570214c

[root@seafile-server-opts seafile]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@seafile-server-opts seafile]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED       STATUS                   PORTS     NAMES
0940a570214c   hello-world   "/hello"   3 hours ago   Exited (0) 3 hours ago             vibrant_pasteur
[root@seafile-server-opts seafile]# docker rm 0940a570214c
0940a570214c
[root@seafile-server-opts seafile]# docker-compose up -d

 

docker-compose logs -f #查看docker启动运行日志

查看代码
 [root@seafile-server-opts seafile]# docker-compose logs -f
seafile-mysql      | 2025-01-24 09:30:01+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.10+maria~ubu2204 started.
seafile            | *** Running /etc/my_init.d/01_create_data_links.sh...
seafile            | *** Booting runit daemon...
seafile            | *** Runit started as PID 21
seafile-caddy      | {"level":"info","ts":1737711001.9328132,"logger":"docker-proxy","msg":"Running caddy proxy server"}
seafile-caddy      | {"level":"info","ts":1737711001.933381,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
seafile-caddy      | {"level":"info","ts":1737711001.9335036,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
seafile-caddy      | {"level":"info","ts":1737711001.9335093,"logger":"docker-proxy","msg":"Running caddy proxy controller"}
seafile-caddy      | {"level":"info","ts":1737711001.9339895,"logger":"docker-proxy","msg":"Start","CaddyfilePath":"","EnvFile":"","LabelPrefix":"caddy","PollingInterval":30,"ProxyServiceTasks":true,"ProcessCaddyfile":true,"ScanStoppedContainers":false,"IngressNetworks":"[seafile-net]","DockerSockets":[""],"DockerCertsPath":[""],"DockerAPIsVersion":[""]}
seafile-caddy      | {"level":"info","ts":1737711001.9345274,"logger":"docker-proxy","msg":"Connecting to docker events","DockerSocket":""}
seafile-caddy      | {"level":"info","ts":1737711001.934756,"logger":"docker-proxy","msg":"IngressNetworksMap","ingres":"map[503feb174e4ad5300d0cf614472c0404c88c91c2ed03c61d70c1181ec38a73aa:true seafile-net:true]"}
seafile-caddy      | {"level":"info","ts":1737711001.9407673,"logger":"docker-proxy","msg":"Swarm is available","new":false}
seafile-caddy      | {"level":"info","ts":1737711001.9419498,"logger":"docker-proxy","msg":"New Caddyfile","caddyfile":"# Empty caddyfile"}
seafile            | *** Running /scripts/enterpoint.sh...
seafile            | 2025-01-24 17:30:22 Nginx ready
seafile            | 2025-01-24 17:30:22 This is an idle script (infinite loop) to keep container running.
seafile            | [2025-01-24 17:30:22] Skip running setup-seafile-mysql.py because there is existing seafile-data folder.
seafile            | [01/24/2025 17:30:22][upgrade]: The container was recreated, start fix the media symlinks
seafile            | mv: not replacing '/shared/seafile/seahub-data/avatars/default-non-register.jpg'
seafile            | mv: not replacing '/shared/seafile/seahub-data/avatars/default.png'
seafile            | mv: not replacing '/shared/seafile/seahub-data/avatars/groups'
seafile            | [01/24/2025 17:30:22][upgrade]: Done
seafile            |
seafile            | Starting seafile server, please wait ...
seafile            | Seafile server started
seafile-caddy      | {"level":"warn","ts":1737711001.9421296,"logger":"docker-proxy","msg":"Caddyfile to json warning","warn":"[Caddyfile:1: Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies]"}
seafile-caddy      | {"level":"info","ts":1737711001.9421353,"logger":"docker-proxy","msg":"New Config JSON","json":"{}"}
seafile-caddy      | {"level":"info","ts":1737711001.942154,"logger":"docker-proxy","msg":"Sending configuration to","server":"localhost"}
seafile-caddy      | {"level":"info","ts":1737711001.9425411,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"33226","headers":{"Accept-Encoding":["gzip"],"Content-Length":["41"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]}}
seafile-caddy      | {"level":"info","ts":1737711001.9425626,"msg":"config is unchanged"}
seafile-caddy      | {"level":"info","ts":1737711001.942566,"logger":"admin.api","msg":"load complete"}
seafile-caddy      | {"level":"info","ts":1737711001.9426112,"logger":"docker-proxy","msg":"Successfully configured","server":"localhost"}
seafile-caddy      | {"level":"info","ts":1737711022.6238637,"logger":"docker-proxy","msg":"New Caddyfile","caddyfile":"http://10.203.29.100 {\n\treverse_proxy 172.18.0.5:80\n}\n"}
seafile-caddy      | {"level":"info","ts":1737711022.6242716,"logger":"docker-proxy","msg":"New Config JSON","json":"{\"apps\":{\"http\":{\"servers\":{\"srv0\":{\"listen\":[\":80\"],\"routes\":[{\"match\":[{\"host\":[\"10.203.29.100\"]}],\"handle\":[{\"handler\":\"subroute\",\"routes\":[{\"handle\":[{\"handler\":\"reverse_proxy\",\"upstreams\":[{\"dial\":\"172.18.0.5:80\"}]}]}]}],\"terminal\":true}]}}}}}"}
seafile-caddy      | {"level":"info","ts":1737711022.6242864,"logger":"docker-proxy","msg":"Sending configuration to","server":"localhost"}
seafile-caddy      | {"level":"info","ts":1737711022.6244116,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"33226","headers":{"Accept-Encoding":["gzip"],"Content-Length":["288"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]}}
seafile            |
seafile            | Done.
seafile            |
seafile            | Starting seahub at port 8000 ...
seafile            |
seafile            | Seahub is started
seafile            |
seafile            | Done.
seafile            |
seafile-mysql      | 2025-01-24 09:30:02+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/memory:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 12:perf_event:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 11:cpuset:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 10:devices:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 9:blkio:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 8:net_cls,net_prio:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 7:freezer:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 6:pids:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 5:ioasids:/
seafile-mysql      | 4:hugetlb:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 3:rdma:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 2:cpu,cpuacct:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope
seafile-mysql      | 1:name=systemd:/system.slice/docker-795eeccd901d91837d98f7d557d55e984ad7b84d5a266ad2d2dea1a4b3076aea.scope/memory.pressure not writable, functionality unavailable to MariaDB
seafile-mysql      | 2025-01-24 09:30:02+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
seafile-mysql      | 2025-01-24 09:30:02+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.10+maria~ubu2204 started.
seafile-mysql      | 2025-01-24 09:30:02+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] Starting MariaDB 10.11.10-MariaDB-ubu2204 source revision 3d0fb150289716ca75cd64d62823cf715ee47646 server_uid KYlPHMUTEacoe6+PM/1u7YtxeCI= as process 1
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Number of transaction pools: 1
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Using generic crc32 instructions
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
seafile-mysql      | 2025-01-24  9:30:02 0 [Warning] mariadbd: io_uring_queue_init() failed with errno 1
seafile-caddy      | {"level":"info","ts":1737711022.624793,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
seafile-caddy      | {"level":"warn","ts":1737711022.6249056,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
seafile-caddy      | {"level":"info","ts":1737711022.6250439,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
seafile-caddy      | {"level":"info","ts":1737711022.62513,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
seafile-caddy      | {"level":"info","ts":1737711022.625134,"logger":"admin.api","msg":"load complete"}
seafile-caddy      | {"level":"info","ts":1737711022.6252437,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
seafile-caddy      | {"level":"info","ts":1737711022.6252604,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000689900"}
seafile-caddy      | {"level":"info","ts":1737711022.6254652,"logger":"docker-proxy","msg":"Successfully configured","server":"localhost"}
seafile-mysql      | 2025-01-24  9:30:02 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Completed initialization of buffer pool
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: End of log at LSN=1103852
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: 128 rollback segments are active.
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: log sequence number 1103852; transaction id 802
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] Plugin 'FEEDBACK' is disabled.
seafile-mysql      | 2025-01-24  9:30:02 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] Server socket created on IP: '0.0.0.0'.
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] Server socket created on IP: '::'.
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] mariadbd: ready for connections.
seafile-mysql      | Version: '10.11.10-MariaDB-ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
seafile-mysql      | 2025-01-24  9:30:02 0 [Note] InnoDB: Buffer pool(s) load completed at 250124  9:30:02
seafile-mysql      | 2025-01-24  9:30:26 8 [Warning] Aborted connection 8 to db: 'seahub_db' user: 'seafile' host: '172.18.0.5' (Got an error reading communication packets)
seafile-caddy      | {"level":"info","ts":1737711022.6261883,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/data/caddy","instance":"bdcf3206-0fe4-4753-8ee4-4705f5f7eb43","try_again":1737797422.6261876,"try_again_in":86399.99999964}
seafile-caddy      | {"level":"info","ts":1737711022.626221,"logger":"tls","msg":"finished cleaning storage units"}

seafile的启动,需要在有seafile-server.yml的路径下,执行docker compose up -d

[root@seafile-server-opts seafile]# pwd
/data/seafile
[root@seafile-server-opts seafile]# ls -a
.  ..  caddy.yml  .env  images  seafile-server.yml
[root@seafile-server-opts seafile]#

操作技巧

  1. 使用 docker compose down 命令停止并删除现有容器(这不会影响你的数据卷)。
  2. 然后执行 docker compose up -d 以基于新的配置重新创建并启动容器。

 

posted @   Magiclala  阅读(154)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示