Search code examples
postgresqldockeramazon-ec2docker-composeyaml

YAML Scanner Error: Mapping values are not allowed here


I am trying to deploy my PostgreSQL to a docker container (in an EC2 instance). My YAML file looks like this:

version: ‘3’
service:
  postgres:
  image: ‘postgres: 13.0’
  ports:
    - “5432:5432”

This works in my localhost. However, when I run 'docker-compose up -d' in the EC2 instance, an error is returned:

ERROR: yaml.scanner.ScannerError: mapping values are not allowed here in "./docker-compose.yml", line 4, column 19

I have searched similar threads and tried all possible solutions but to no avail.

Hope someone can help me.

Thanks in advance!


Solution

  • Your compose file has incorrect structure. Indent matters in YAML syntax. So you need to fix it to

    version: '3'
    
    services:
      postgres:
        image: 'postgres: 13.0'
        ports:
          - "5432:5432"
    

    Check the example here: https://hub.docker.com/_/postgres

    P.S. - There are also service instead of services and incorrect quotations in your yaml. Like instead of ' and instead of ".