36

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 3

79

Use spaces instead of tabs and the error will not persist

30

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.

-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.