yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token

Viewed 48570

I am trying to create node and mongo service and run them in the same network using the docker compose file but it showing me this error "yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token" when i run docker-compose build command

can anyone please help me.

this is my docker-compose.yml file

version: '3'
services:
    node:
        build:
            context: .
            dockerfile: node.dockerfile
        ports:
            - "3000:3000"
        networks: 
            - nodeapp-network
    mongodb:
        image: mongo
        networks: 
            - nodeapp-network

networks: 
  nodeapp-network:
    driver: bridge
3 Answers

Use spaces instead of tabs and the error will not persist

You may be using "tab" to indent your YAML file.

The "tab" is not permitted by the YAML specs:

To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently. Note that most modern editors may be configured so that pressing the tab key results in the insertion of an appropriate number of spaces.

If you are using xcode to open the .ymlfile then check this out:

In case ur xCode settings configured for text editing with tab, then you can it change it to spaces like this:

Go to xCode preference using cmd + ,

enter image description here

Related