简体   繁体   English

尝试将数据持久化到卷时出现docker-compose.yml错误

[英]docker-compose.yml error while trying to persist data on a volume

In my Docker Instance, I created a volume called jokes . 在我的Docker实例中,我创建了一个名为jokes的卷。 I'm trying to build out my service now with docker-compose up but I keep getting this error message: 我正在尝试使用docker-compose up建立我的服务docker-compose up但我不断收到以下错误消息:

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.db.volumes contains an invalid type, it should be an array

Here is my docker-compose.yml file: 这是我docker-compose.yml文件:

version: '3.6'
services:
  web:
    build: .
    command: puma
    depends_on:
      - db
    environment:
      DATABASE_URL: "postgres://postgres@db"
    ports:
      - "3000:3000"
    volumes:
      - "./:/app"
    working_dir: /app
  db:
    image: "postgres:10.3-alpine"
    volumes: "-jokes: /var/lib/postgresql/data"
volumes:
  jokes: ~

How should I fix this? 我该如何解决?

How should I fix this? 我该如何解决?

As detailed in the official documentation you are required to give a list there (hence complaint about list), so move hyphen outside the quotes like so: 官方文档所述,您需要在此处提供一个列表(因此会抱怨列表),因此请在引号外加上连字符,如下所示:

volumes: 
  - "jokes:/var/lib/postgresql/data"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 docker-compose.yml:指定 tmpfs 卷时出错 - docker-compose.yml: Error while specifying a tmpfs volume 错误:在文件“ ./docker-compose.yml”中,卷必须是映射,而不是数组 - ERROR: In file './docker-compose.yml', volume must be a mapping, not an array 尝试运行 docker-compose.yml 文件时收到拉取访问被拒绝错误 - Receiving pull access denied error while trying to run docker-compose.yml file 在docker-compose.yml上复制'docker volume create --name data'命令 - Replicate 'docker volume create --name data' command on docker-compose.yml 错误:“./docker-compose.yml”中的版本不受支持 - ERROR: Version in "./docker-compose.yml" is unsupported 如何使用docker-compose.yml文件命名卷? - How to name a volume using a docker-compose.yml file? docker-compose.yml在以点(。)开头的文档上使用卷 - docker-compose.yml use volume on documents starting with dot (.) 如何在 docker-compose.yml 中为命名卷设置主机路径 - How to set a path on host for a named volume in docker-compose.yml 在文件 './docker-compose.yml' 中,卷必须是映射,而不是数组 - In file './docker-compose.yml', volume must be a mapping, not an array Pycharm:解析“docker-compose.yml”时出错:进程“docker-compose config”失败 - Pycharm: Error while parsing “docker-compose.yml”: Process `docker-compose config` failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM