How do I fix my Docker-Compose.yml? expected <block end>, but found '<block Mapping start>'

Asked

Viewed 1,821 times

1

$ docker-compose up
ERROR: yaml.parser.ParserError: while parsing a block mapping
  in ".\docker-compose.yml", line 3, column 4
expected <block end>, but found '<block mapping start>'
  in ".\docker-compose.yml", line 6, column 5

It seems that there is a problem in my yml file. I read some other questions here, and tried several schemes and still can’t make it work.

I wonder where you’re wrong?

version: '3'
services: 
   kwan:
      image: postgres:11.5
      network_mode: bridge
    container_name: postgres
    volumes:
      - postgres-data:/var/lib/postgresql/data
    expose:
    - 5432
    ports:
      - 5432:5432
    environment:
         - POSTGRES_PASSWORD=root
         - POSTGRES_USER=postgres
         - POSTGRES_DB=root
    restart: unless-stopped
  backend:
       build: .

See how you find yourself;

inserir a descrição da imagem aqui

This is my Dockerfile file;

FROM 8u131-jdk-alpine

MAINTAINER Wladimir Bandeira "[email protected]"

EXPOSE 8080

WORKDIR /usr/local/bin/

COPY dockerTest-1.0.0-SNAPSHOT.jar webapp.jar

CMD ["java","-Dspring.profiles.active=docker-demo","-jar","webapp.jar"]

1 answer

2


Apparently, their indentation is wrong. Yml files use tabs or spaces to delimit blocks in a similar way to python.

container_name, volumes, expose,ports, environment and restart are out of kwan.

Try to adjust to

version: '3'
services: 
   kwan:
      image: postgres:11.5
      network_mode: bridge
      container_name: postgres
      volumes:
        - postgres-data:/var/lib/postgresql/data
      expose:
      - 5432
      ports:
        - 5432:5432
      environment:
          - POSTGRES_PASSWORD=root
          - POSTGRES_USER=postgres
          - POSTGRES_DB=root
      restart: unless-stopped
  backend:
       build: .

I think that will solve

  • thank you very much, it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.