docker-compse.yml添加如下内容
version: '2.0'
services:
office-preview:
image: seafileltd/office-preview:latest
container_name: seafile-office-preview
ports:
- "8089:8089"
command: bash start.sh
volumes:
- ${PWD}/office-preview/shared:/shared ##宿主机路径可以自定义
networks:
- seafile-net
完整版docker-compose.yml内容
version: '2.0'
services:
office-preview:
image: seafileltd/office-preview:latest
container_name: seafile-office-preview
ports:
- "8089:8089"
command: bash start.sh
volumes:
- ${PWD}/office-preview/shared:/shared ##宿主机路径可以自定义
networks:
- seafile-net
db:
image: mariadb:10.5
container_name: seafile-mysql
environment:
- MYSQL_ROOT_PASSWORD=db_dev # Requested, set the root's password of MySQL service.
- MYSQL_LOG_CONSOLE=true
volumes:
- ${PWD}/seafile-mysql/db:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
networks:
- seafile-net
memcached:
image: memcached:1.6
container_name: seafile-memcached
entrypoint: memcached -m 256
networks:
- seafile-net
seafile:
image: seafileltd/seafile-mc:latest
container_name: seafile
ports:
- "80:80"
# - "443:443" # If https is enabled, cancel the comment.
volumes:
- ${PWD}/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=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
- SEAFILE_ADMIN_PASSWORD=asecret # Specifies Seafile admin password, default is 'asecret'.
- SEAFILE_SERVER_LETSENCRYPT=false # Whether use letsencrypt to generate cert.
- SEAFILE_SERVER_HOSTNAME=seafile.example.com # Specifies your host name.
depends_on:
- db
- memcached
networks:
- seafile-net
networks:
seafile-net:
添加后重启docker-compose容器
docker-compose up -d重启后在office-preview/shared目录添加office_convertor_settings.py,内容如下
# -*- coding:utf-8 -*-
#和 seafile 的 seahub_settings.py 里的 SECRET_KEY 保持一致
SECRET_KEY = "b'+lr$^+j9m2(o!tp$*0q-&5u4^x%dw10662@p67c51mc0y$tnlb'"
WORKERS = 10 # worker 数
OUTPUT_DIR = '/shared/output' # 输出目录,容器内目录
PORT = 8089 # 服务端口,容器内端口,非映射到外部的端口并修改权限为755
chmod 755 office_convertor_settings.py在seafile容器中增加office预览配置
进入seafile容器
docker exec -it seafile bash
cd conf
编辑conf目录下的seahub_settings.py,添加如下配置
OFFICE_CONVERTOR_ROOT = 'http://seafile-office-preview:8089'http后面跟office的容器名即可,即使重启docker-compose导致容器漂移也不用重配ip
最后上系统配置界面看上传下载地址是否配好。

配好之后就能正常工作了,2M以内的office文件都能预览,超过了必须下载


版权声明:本文为gsls200808原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。