【问题标题】:Docker Compose / Invalid BecauseDocker Compose / 无效,因为
【发布时间】:2020-01-11 13:45:24
【问题描述】:

我想运行 docker-compose.yaml 文件,但出现以下错误:

“无效,因为: services.eventstore.volumes 包含无效类型,它应该是一个数组”。

我将 eventstore 文件备份到我的 Windows 桌面,我想使用 docker 恢复它。

这是我的 docker-compose 文件:

version: '3'
services:
  eventstore:
    image: eventstore/eventstore:release-5.0.1
    container_name: eventstore
    ports:
      - 2113:2113
      - 1113:1113
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:2113/stats || exit 1"]
      interval: 5s
      timeout: 2s
    environment:
      - EVENTSTORE_RUN_PROJECTIONS=all
      - EVENTSTORE_START_STANDARD_PROJECTIONS=TRUE
    volumes:
      -C:/Users/cerdem/Desktop/eventstore:./data
      -C:/Users/cerdem/Desktop/eventstore:./logs

有关更多信息,我在输入volumes 部分后出现错误,因为我无法理解该部分,我将从local 而不是host 恢复db 文件。

我的电脑运行的是 windows 1O。

【问题讨论】:

  • 在破折号后尝试了一个空格?

标签: docker docker-compose restore eventstoredb


【解决方案1】:

volumes 键中的破折号后需要空格。

    volumes:
      - C:/Users/cerdem/Desktop/eventstore:./data
      - C:/Users/cerdem/Desktop/eventstore:./logs

它不被识别为数组。因此,类型错误。

“无效,因为:services.eventstore.volumes 包含无效类型,它应该是一个数组”

这是完整版:

services:
  eventstore:
    image: eventstore/eventstore:release-5.0.1
    container_name: eventstore
    ports:
      - 2113:2113
      - 1113:1113
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:2113/stats || exit 1"]
      interval: 5s
      timeout: 2s
    environment:
      - EVENTSTORE_RUN_PROJECTIONS=all
      - EVENTSTORE_START_STANDARD_PROJECTIONS=TRUE
    volumes:
      - C:/Users/cerdem/Desktop/eventstore:./data
      - C:/Users/cerdem/Desktop/eventstore:./logs

【讨论】:

    【解决方案2】:

    你有一些事情发生:

    • 破折号后需要一个空格。
    • 您应该使用“奇怪”字符来包装路径,例如引号中的 .
    • 您需要以 Docker 喜欢的方式格式化 Windows 路径。

        volumes:
          - '/c/Users/cerdem/Desktop/eventstore:./data'
          - '/c/Users/cerdem/Desktop/eventstore:./logs'
    

    顺便说一句,如果您有兴趣,我编写了一个方便的小脚本,以便更轻松地处理频繁的 Windows-2-Docker 路径转换。

    https://stackoverflow.com/a/54619756/553663

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 2019-08-07
      • 2017-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多