我想创建一个 .yml文件,我可以执行该文件以将wordpress与mysql一起使用。我是关于docker composoe的docker的新手,所以我的代码是:
web:
image: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_PASSWORD=sample
ports:
- "127.0.0.3:8080:80"
mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=sample
- MYSQL_DATABASE=wordpress
我做docker-compose up
并收到此错误:
ERROR: In file './docker-compose.yml', service 'image' must be a mapping not a string.
有人可以帮助我吗?
答案 0 :(得分:3)
这是Yaml格式错误。 您应该这样格式化
web:
image: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_PASSWORD=sample
ports:
- "127.0.0.3:8080:80"
mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=sample
- MYSQL_DATABASE=wordpress
答案 1 :(得分:1)
mysql:
附近的缩进是错误的,请按以下说明更正缩进
web:
image: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_PASSWORD=sample
ports:
- "127.0.0.3:8080:80"
mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=sample
- MYSQL_DATABASE=wordpress