带有 OnlyOffice 的 NextCloud 无法打开以前保存的文档

NextCloud with OnlyOffice not opening previosly saved documents

OnlyOffice 在执行 docker-compose down 后不打开以前保存的文档。我需要增加 nextcloud 实例(docker 容器)的内存,所以我继续停止所有容器,修改 docker-compose 并重新设置所有内容。

到目前为止,新文档没有问题,但编辑以前保存的文档时,OnlyOffice 打开一个空白文档,文件大小完好无损(控制台中没有错误),在 NextCloud 中仍然显示 KB。

version: "2.3"
services:
  nextcloud:
    container_name: nextcloud
    image: nextcloud:latest
    hostname: MYDOMAIN
    stdin_open: true
    tty: true
    restart: always
    expose:
      - "80"
    networks:
      - cloud_network
    volumes:
      - /mnt/apps/nextcloud/data:/var/www/html
    environment:
      - MYSQL_HOST=mariadb
      - PHP_MEMORY_LIMIT=-1
    env_file:
      - db.env
    mem_limit: 8g
    depends_on:
      - mariadb

  mariadb:
    container_name: mariadb
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed
    restart: always
    networks:
      - cloud_network
    volumes:
      - mariadb_volume:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=SOMEPASSWORD
    env_file:
      - db.env

  onlyoffice:
    container_name: onlyoffice
    image: onlyoffice/documentserver:latest
    stdin_open: true
    tty: true
    restart: always
    networks:
      - cloud_network
    expose:
      - "80"
    volumes:
      #- /mnt/apps/onlyoffice/data:/var/www/onlyoffice/Data
      - office_data_volume:/var/www/onlyoffice/Data
      #- onlyoffice_log_volume:/var/log/onlyoffice
      - office_db_volume:/var/lib/postgresql

  caddy:
    container_name: caddy
    image: abiosoft/caddy:no-stats
    stdin_open: true
    tty: true
    restart: always
    ports:
      - 80:80
      - 443:443
    networks:
      - cloud_network
    environment:
      - CADDYPATH=/certs
      - ACME_AGREE=true
      # CHANGE THESE OR THE CONTAINER WILL FAIL TO RUN
      - CADDY_LETSENCRYPT_EMAIL=MYEMAIL
      - CADDY_EXTERNAL_DOMAIN=MYDOMAIN
    volumes:
      - /mnt/apps/caddy/certs:/certs:rw
      - /mnt/apps/caddy/Caddyfile:/etc/Caddyfile:ro

networks:
  cloud_network:
    driver: "bridge"

volumes:
  office_data_volume:
  office_db_volume:
  mariadb_volume:

似乎每次在 NextCloud + OnlyOffice 设置中安装容器时,它都会生成令牌以授权通过 headers 访问文档。

我通过添加第三个 docker 卷来保存文档服务器文件来解决它。幸运的是,我备份了我的文件,我删除了容器并再次添加它们,现在一切正常。

- office_config_volume:/etc/onlyoffice/documentserver

onlyoffice:
    container_name: onlyoffice
    image: onlyoffice/documentserver:latest
    stdin_open: true
    tty: true
    restart: unless-stopped
    networks:
        - cloud_network
    expose:
        - "80"
    volumes:
        - office_data_volume:/var/www/onlyoffice/Data
        - office_db_volume:/var/lib/postgresql
        - office_config_volume:/etc/onlyoffice/documentserver

另请注意,在 stop/restart 您的容器之前,您必须始终 断开用户连接。参见 https://github.com/ONLYOFFICE/Docker-DocumentServer#document-server-usage-issues

sudo docker exec onlyoffice documentserver-prepare4shutdown.sh