Raghav Mri
Raghav Mri

Reputation: 35

Docker-Compose file throwing yaml.scanner.ScannerError error

This is how my docker-compose file looks

version: '3.3'
    services:
        frontend:
            ports:
                - 8000:8000
            build: ./frontend
        api:
            build: ./api
            ports: 
                - 8080:8080
        reverse-proxy:
            image: nginx:1.21
            depends_on: 
                - api
                - frontend
            volumes:
                - ./nginx-conf:/etc/nginx/conf.d
            ports: 
            - 80:80
            - 443:443

i if I run docker-compose build on the above file I am getting the following error

ERROR: compose.cli.main.main: yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token in "./docker-compose.yaml", line 3, column 1

I have tried changing the version as well as correcting the spaces/tabs but nothing works

Upvotes: 0

Views: 453

Answers (1)

Saeed
Saeed

Reputation: 4133

The indentation of services and version should be at the same level, so your docker-compose file should look like this:

version: '3.3'

services:
    frontend:
        ports:
            - 8000:8000
        build: ./frontend
    api:
        build: ./api
        ports: 
            - 8080:8080
    reverse-proxy:
        image: nginx:1.21
        depends_on: 
            - api
            - frontend
        volumes:
            - ./nginx-conf:/etc/nginx/conf.d
        ports: 
        - 80:80
        - 443:443

Upvotes: 1

Related Questions