简体   繁体   English

Docker-compose:在启用spring boot和spring cloud config应用程序时出现问题

[英]Docker-compose: Issue while running the spring boot enabled and spring cloud config application

I want to run the Spring Boot enabled and spring cloud config project to deploy to Docker. 我想运行Spring Boot和Spring cloud配置项目来部署到Docker。 The below is the docker-compose.yml file. 以下是docker-compose.yml文件。 But I'm getting the following error while running the file. 但是我在运行文件时遇到以下错误。

Error: 错误:

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

Below is my docker-compose.yml file: 下面是我的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

I have tried multiple indentations changes for docker-compose.yml file. 我已尝试对docker-compose.yml文件进行多次缩进更改。

The mentioned services are already built by maven. 提到的服务已经由maven构建。 Need help in running the docker composer for the application. 在为应用程序运行docker composer时需要帮助。

There are multiple errors. 有多个错误。

  1. Make sure that you only use spaces for indentation (instead of tabs). 确保只使用空格进行缩进(而不是制表符)。 If you are interested why tabs don't work within yaml files have a look at A YAML file cannot contain tabs as indentation 如果您有兴趣为什么选项卡在yaml文件中不起作用,请查看A YAML文件不能包含标签作为缩进
  2. put your ports into strings (eg - "8060:8060" instead of - 8060:8060 ) 将您的端口放入字符串(例如- "8060:8060"而不是- 8060:8060
  3. I think you are misusing environment variables. 我认为你是在滥用环境变量。 They should/must look like eg: 他们应该/必须看起来像,例如:

environment: - JAVA_OPTS - EUREKA_SERVER=http://discovery:8761/eureka - ANOTHER_ENV_VARIABLE=/config-data

Have a look at the docs for details: https://docs.docker.com/compose/environment-variables/ 详细了解文档: https//docs.docker.com/compose/environment-variables/

After fixing your docker-compose.yml you can validate your file by running docker-compose config inside of the directory where your docker-compose.yml is located. 修复docker-compose.yml后,您可以通过在docker-compose.yml所在目录中运行docker docker-compose config来验证您的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在docker-compose的Spring Boot应用程序中使用外部配置 - Using external config in spring boot application within docker-compose 在 Docker-compose 中使用 Kafka 运行 Spring Boot 应用程序 - Running Spring Boot application with Kafka in Docker-compose 用于本地 Spring Boot 开发的 Docker-Compose - Docker-Compose for local Spring Boot Development 如何使用 Docker-compose 在 Docker 上连接 Spring Boot 和 MySQL? - How to connect between Spring Boot and MySQL on Docker with Docker-compose? 无法使用 Spring Boot 应用程序使 Keycloak 在 docker-compose 内工作 - Cannot make Keycloak work inside docker-compose with Spring Boot application 在客户端重新启动之前,无法使用 docker-compose 访问 Spring Config 服务器 - Spring Config server not reachable with docker-compose until client is restarted docker-compose 推送多个服务 Spring 引导 MySQL - docker-compose push Multiple Services Spring Boot MySQL Spring Boot应用程序未与Cloud Config Server连接 - Spring Boot application not connecting with Cloud Config Server 在 Spring Boot 应用程序的测试类中禁用 Spring Cloud Config 的自动配置 - Disable autoconfiguration for Spring Cloud Config in a test class of a Spring Boot application 无法加载 Spring 在 Docker 中运行的引导应用程序 - Unable to load Spring Boot application running in Docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM