错误:在文件“ ./docker-compose.yml”中,卷必须是映射而不是字符串 [英] ERROR: In file './docker-compose.yml', volume must be a mapping not a string
本文介绍了错误:在文件“ ./docker-compose.yml”中,卷必须是映射而不是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题:
为什么会出现此错误?
Question: Why do I get this error?
错误:在文件 ./docker-compose.yml中,卷 mariavolume必须是映射而不是字符串。
ERROR: In file './docker-compose.yml', volume 'mariavolume' must be a mapping not a string.
我的docker-compose文件与此几乎相同: https://docs.docker.com/compose/wordpress/
My docker-compose file is almost identical to this one: https://docs.docker.com/compose/wordpress/
version: '2'
services:
wordpress:
image: wordpress:latest
restart: always
depends_on:
- db
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
WORDPRESS_DB_HOST: 3306
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- maria_volume: /var/lib/mysql
volumes:
maria_volume: ~/mariadb
推荐答案
在我的情况下,这是因为我错过了添加:
卷名之后。
In my case this was happening because I missed adding a :
after the volume name.
而不是:
volumes:
- mysqldata:
我输入过:
volumes:
- mysqldata
docker-compose up
给了我与上面相同的错误。
docker-compose up
gave me the same error as above.
这篇关于错误:在文件“ ./docker-compose.yml”中,卷必须是映射而不是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文