yaml.parser.ParserError: while parsing a block mapping

Question: Docker-Compose.yaml error: yaml.parser.ParserError: while parsing a block mapping
  in "./docker-compose.yml", line 3, column 3
expected <block end>, but found '<block mapping start>'
  in "./docker-compose.yml", line 17, column 5


Please Login to see the rest of the answer

Answer: When defining multiple Services in one single docker-compose.yaml you have to make sure that the Services are defined one after the other.

1. Pay attention to the positioning of blocks of code under one specific Service See the Code below:

version: "3.2"
services:
  nameOfServiceHere:
      image: "theImageYouWant"
      container_name: the-name-you-want
      ports:
        - "portOnHost:portOnDockerContainer" 
      environment:
        - Key=valueOfKey
      restart: always
      volumes:
        - /muiltTheVolumeHere
  
  another-Service-Name-here:
    image: "ImageHere"
    container_name: name-of-container
    ports:
      - "port:port" 
    environment:
      - Key=value
      - Key="value"
    restart: always
    volumes:
      - /BindVolume

  another-service:
    image: "image"
    container_name: containername
    ports:
      - "port:port" 
    environment:
      - Key=value
    restart: always
    volumes:
      - /Directory
volumes:
  yourdata:

Write an Article
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy