Docker-compose 本地目录映射被忽略,docker 卷被替代

Docker-compose local directory mappings are ignored, docker volumes are used instead

这是我第一次设置 owncloud,我正在尝试使用 docker-compose 来完成。我使用的 YAML 文件如下:

version: "3"

services:
  owncloud:
    image: owncloud/server:latest
    container_name: owncloud_server
    restart: always
    ports:
      - 1234:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=owncloud.mydomain.net
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=passwd
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=user-admin
      - OWNCLOUD_ADMIN_PASSWORD=passwd
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    volumes:
      - /mnt/volume-nbg1-1/owncloud/files:/var/www/html/files
      - /mnt/volume-nbg1-1/owncloud/config:/var/www/html/config
      - /mnt/volume-nbg1-1/owncloud/apps:/var/www/html/apps
      - /mnt/volume-nbg1-1/owncloud/sessions:/var/www/html/sessions

  mariadb:
    image: mariadb:10.5
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=passwd
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=passwd
      - MYSQL_DATABASE=owncloud
    volumes:
      - /mnt/volume-nbg1-1/owncloud/mariadb:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    volumes:
      - /mnt/volume-nbg1-1/owncloud/redis:/data

我的问题是,虽然 Redis 和 MariaDB 目录在部署时已正确创建和填充,owncloud 安装的目录似乎已正确创建,但随后还在 [=17= 中创建了一个 docker 卷]//_data,然后其中的目录将被填充。 owncloud.log 是空的,所以我无法从中得到任何提示。我也试过将 /mnt/volume-nbg1-1 内的 owncloud 目录的所有者更改为 docker 用户,但这并没有改变任何东西。对我做错了什么有什么想法吗?

检查 owncloud/server:latest 图像显示他们在其中定义的体积 /mnt/data。因此,您需要为此定义一个卷,以避免 docker 默认创建的匿名卷。例如:

version: "3"

services:
  owncloud:
    image: owncloud/server:latest
    container_name: owncloud_server
    restart: always
    ports:
      - 1234:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=owncloud.mydomain.net
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=passwd
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=user-admin
      - OWNCLOUD_ADMIN_PASSWORD=passwd
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    volumes:
      - owncloud-data:/mnt/data
      - /mnt/volume-nbg1-1/owncloud/files:/var/www/html/files
      - /mnt/volume-nbg1-1/owncloud/config:/var/www/html/config
      - /mnt/volume-nbg1-1/owncloud/apps:/var/www/html/apps
      - /mnt/volume-nbg1-1/owncloud/sessions:/var/www/html/sessions

  mariadb:
    image: mariadb:10.5
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=passwd
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=passwd
      - MYSQL_DATABASE=owncloud
    volumes:
      - /mnt/volume-nbg1-1/owncloud/mariadb:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    volumes:
      - /mnt/volume-nbg1-1/owncloud/redis:/data

volumes:
  owncloud-data:

请注意,我在这里切换到命名卷,因为我不知道该目录或它期望的目录 owner/permissions 的初始内容。