gpt4 book ai didi

docker - 此处不允许yml docker-compose错误映射值

转载 作者:行者123 更新时间:2023-12-02 20:44:17 34 4
gpt4 key购买 nike

我尝试了解容器,但是我的docker-compose.yml文件有问题,在运行docker compose之后,我总是会遇到相同的错误:

"ERROR: yaml.scanner.ScannerError: mapping values are not allowed here"



即使我将安装路径更改为docker volume,我也遇到了同样的错误,这是我的 yml文件
version: "3"

services:
database:
image: mariadb
ports:
- "3260:3260"
volumes:
- /home/randy/Desktop/Latihan/wordpress-mariadb/mariadb:var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root

wordpress:
image: wordpress
ports:
- "2000:80"
volumes:
- /home/randy/Desktop/Latihan/wordpress-mariadb/wordpress:/var/www/html
environment:
WORDPRESS_DB_PASSWORD: root
depends_on:
- database
links:
- database

最佳答案

您的Yaml似乎无效。当我遇到这些类型的问题时,我将使用名为http://www.yamllint.com/的站点来为您验证语法。

根据您的示例,这个Yaml是有效的:

注意:您可以使用4个空格(或2个我更喜欢的空格),但决不能使用制表符。

version: "3"

services:
database:
environment:
MYSQL_ROOT_PASSWORD: root
image: mariadb
ports:
- "3260:3260"
volumes:
- "/home/randy/Desktop/Latihan/wordpress-mariadb/mariadb:var/lib/mysql"
wordpress:
image: wordpress
ports:
- "2000:80"
volumes:
- /home/randy/Desktop/Latihan/wordpress-mariadb/wordpress:/var/www/html
environment:
WORDPRESS_DB_PASSWORD: root
depends_on:
- database
links:
- database

关于docker - 此处不允许yml docker-compose错误映射值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57959973/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com