简体   繁体   中英

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. The below is the docker-compose.yml file. 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:

    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.

The mentioned services are already built by maven. Need help in running the docker composer for the application.

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
  2. put your ports into strings (eg - "8060:8060" instead of - 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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM