[英]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.