我想运行启用了Spring Boot的Spring Cloud配置项目以部署到Docker。以下是docker-compose.yml文件。但是运行文件时出现以下错误。
错误:
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 4, column 4
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 48, column 5
以下是我的 docker-compose.yml 文件:
version: '3'
services:
discovery:
image: pl.app.service/discovery-service:0.0.1-SNAPSHOT
ports:
- 8061:8061
config:
image: pl.app.service/config-service:0.0.1-SNAPSHOT
volumes:
- ./config-data:/config-data
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
-Dspring.cloud.config.server.native.searchLocations=/config-data
depends_on:
- discovery
ports:
- 8088:8088
proxy-service:
image: pl.app.service/proxy-service:0.0.1-SNAPSHOT
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
depends_on:
- discovery
- config
ports:
-8060:8060
employee-service:
image: pl.app.service/employee-service:0.0.1-SNAPSHOT
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
-Dspring.profiles.active=dev
restart: on-failure
depends_on:
- discovery
- config
ports:
-8090:8090
department-service:
image: pl.app.service/organization-service:0.0.1-SNAPSHOT
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
-Dspring.profiles.active=dev
restart: on-failure
depends_on:
- discovery
- config
ports:
-8091:8091
organization-service:
image: pl.app.service/organization-service:0.0.1-SNAPSHOT
environment:
- JAVA_OPTS=
-DEUREKA_SERVER=http://discovery:8761/eureka
-Dspring.profiles.active=dev
restart: on-failure
depends_on:
- discovery
- config
ports:
-8092:8092
我尝试对docker-compose.yml文件进行多个缩进更改。
提到的服务已经由maven构建。在运行该应用程序的docker composer时需要帮助。
答案 0 :(得分:0)
有多个错误。
SELECT id,
max(case when sortid=2 then StrValue end),
max(case when sortid=3 then StrValue end),
max(case when sortid=5 then StrValue end)
FROM tablename
GROUP BY id
而不是- "8060:8060"
) - 8060:8060
有关详细信息,请参阅文档:https://docs.docker.com/compose/environment-variables/
修复docker-compose.yml后,您可以通过在docker-compose.yml所在目录内运行environment:
- JAVA_OPTS
- EUREKA_SERVER=http://discovery:8761/eureka
- ANOTHER_ENV_VARIABLE=/config-data
来验证文件。