我有以下文件./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
Run Code Online (Sandbox Code Playgroud)
当我运行时cd ./wordpress && docker-compose up -d,出现以下错误:
ERROR: In file './docker-compose.yaml', volume must be a mapping, not a string.
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我做错了什么?
首先有某些拼写错误,例如serivces, evironment。他们应该拼写services和environment。同样对于“...不是字符串”错误,只需在卷名后附加“:”,如下所示
volumes:
db_data:
| 归档时间: |
|
| 查看次数: |
13174 次 |
| 最近记录: |