docker-compose:在卷部分没有找到声明

Lux*_*dev 6 windows docker seafile-server docker-compose

我尝试在 Microsoft Windows 上使用 Docker-Compose 为 Seafile 创建堆栈。

\n

创建后的错误信息是:

\n
\n

部署错误\n部署堆栈失败:命名卷 \xe2\x80\x9cC:/Users/Administrator/Docker/Volumes/Seafile/Mysql:/var/lib/mysql:rw\xe2\x80\x9d 在服务中使用 \ xe2\x80\x9cdb\xe2\x80\x9d 但在卷部分没有找到声明。:退出状态1

\n
\n

这是我有问题的docker-compose.yaml文件:

\n
version: \'2\'\nservices:\n  db:\n    image: mariadb:10.5\n    container_name: seafile-mysql\n    environment:\n      - MYSQL_ROOT_PASSWORD=db_dev  # Requested, set the root\'s password of MySQL service.\n      - MYSQL_LOG_CONSOLE=true\n    volumes:\n      - C:/Users/Administrator/Docker/Volumes/Seafile/Mysql:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.\n    networks:\n      - seafile-net\n\n  memcached:\n    image: memcached:1.5.6\n    container_name: seafile-memcached\n    entrypoint: memcached -m 256\n    networks:\n      - seafile-net\n          \n  seafile:\n    image: seafileltd/seafile-mc:latest\n    container_name: seafile\n    ports:\n      - "9000:80"\n#     - "443:443"  # If https is enabled, cancel the comment.\n    volumes:\n      - C:/Users/Administrator/Docker/Volumes/Seafile/Seafile:/shared   # Requested, specifies the path to Seafile data persistent store.\n    environment:\n      - DB_HOST=db\n      - DB_ROOT_PASSWD=db_dev  # Requested, the value shuold be root\'s password of MySQL service.\n      - TIME_ZONE=Etc/UTC  # Optional, default is UTC. Should be uncomment and set to your local time zone.\n      - SEAFILE_ADMIN_EMAIL=me@example.com  # Specifies Seafile admin user, default is \'me@example.com\'.\n      - SEAFILE_ADMIN_PASSWORD=asecret     # Specifies Seafile admin password, default is \'asecret\'.\n      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not.\n      - SEAFILE_SERVER_HOSTNAME=docs.seafile.com # Specifies your host name if https is enabled.\n    depends_on:\n      - db\n      - memcached\n    networks:\n      - seafile-net\n\nnetworks:\n  seafile-net:\n
Run Code Online (Sandbox Code Playgroud)\n

Val*_*ozz 7

docker-compose您看到错误“在卷部分中未找到声明”时,您可能没有从 Yaml 配置的根部分声明卷。

\n

快速解释:

\n
...\nservices:\n\n    # This section is needed to use volumes\n    # \xe2\x86\x93\n    volumes:\n      - a:/path1\n      - b:/path2\n\n# This section is needed to declare available volumes\n# \xe2\x86\x93\nvolumes:\n  a:\n  b:\n...\n
Run Code Online (Sandbox Code Playgroud)\n

我知道这可能会以某种方式分散,并且我知道 Docker 可以在另一个宇宙中以不同的方式处理它,并且我知道错误消息可能会引起混乱,但目前它以这种方式工作。

\n

让我知道这是否是您的问题。

\n

更多信息:

\n

https://docs.docker.com/storage/volumes/#use-a-volume-with-docker-compose

\n