Solved: ERROR: Version in “./docker-compose.yml” is invalid & found character ‘\t’ that cannot start any token

In this post, we will look how to resolve two error messages that we can face while writing docker compose file.

Error 1: found character ‘\t’ that cannot start any token

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

Solution
Edit docker-compose.yml file and correct the spacing at the start of lines.
The error message specifies that there is “\t” i.e. a TAB character exists in the start of the line that should be corrected.


Error 2: ERROR: Version in “./docker-compose.yml” is invalid – it should be a string.

$ docker-compose config
ERROR: Version in "./docker-compose.yml" is invalid - it should be a string.

Solution
We need to edit and make sure the version number is inside single quotes i.e. ”.

### Correct file with single quotes and run config command to check no error message is reported.
$ docker-compose config
services:
  database:
    image: redis
  web:
    image: nginx
version: '3.0'

### Corrected file:
$ cat docker-compose.yml
version: '3'

services:

  web:
   image: nginx

  database:
   image: redis

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments