我在./wordpress/docker-compose.yaml
中有以下文件:
version: '3.3'
serivces:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
evironment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
volumes:
- ./:/var/www/html
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data
当我运行
cd ./wordpress && docker-compose up -d
时,出现以下错误:ERROR: In file './docker-compose.yaml', volume must be a mapping, not a string.
谁能告诉我我在做什么错?
最佳答案
首先存在某些拼写错误,例如serivces
,evironment
。他们应该拼写services
和environment
。同样对于“... not string”错误,只需在卷名后附加“:”,如下所示volumes: db_data:
关于Docker卷必须是映射,而不是字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49937772/