错误:在文件“./docker-compose.yml"中,卷必须是映射而不是字符串 [英] ERROR: In file './docker-compose.yml', volume must be a mapping not a string
本文介绍了错误:在文件“./docker-compose.yml"中,卷必须是映射而不是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题:为什么会出现此错误?
错误:在文件./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屋!
查看全文