尝试运行代码以消除类似的错误
yaml.scanner.ScannerError: mapping values are not allowed here
in "./docker-compose.yml", line 15, column 14
YAML文件:
version: '3'
services:
traefik:
image: traefik:latest # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Traefik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
restart: always
service:
build: .
environment:
-MY_MESSAGE=load1
labels:
-'traefik.frontend.rule=Host:load.test'
-'traefik.backend=load'
答案 0 :(得分:0)
这是由于docker-compose文件中的缩进。此外,您还需要遵循syntax of version 3来获取环境变量和标签。
version: '3'
services:
traefik:
image: traefik:latest # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Traefik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
restart: always
service:
build: .
environment:
- MY_MESSAGE= "load1"
labels:
- traefik.frontend.rule:"Host:load.test"
- traefik.backend:"load"