ERROR: Version c. / docker -compose.yml is not supported. You may have noticed this error because you are using the wrong version of the Compose file

Here is the docker-compose.yml file

version: "2" services: web: build: . environment: MONGO_URI="mongodb://ravimongo:27017" ports: β€” "3000:3000" links: β€” ravimongo depends_on: β€” ravimongo ravimongo: image: mongo:3.2.6 ports: β€” "27017:27017" 

Here is the error:

 ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version ("2.0", "2.1", "3.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/ 

Version Information: docker-compose version

 docker-compose version 1.11.2, build dfed245 docker-py version: 2.1.0 CPython version: 2.7.12 OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016 

docker version

 Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: darwin/amd64 Server: Version: 17.03.1-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: c6d412e Built: Fri Mar 24 00:00:50 2017 OS/Arch: linux/amd64 Experimental: true 

I checked the yaml syntax at http://www.yamllint.com/ and https://codebeautify.org/yaml-validator . I can not find the problem.

+8
source share
4 answers

YAML is valid. However, you use the left double quote ' something like this:

version: '2'

Judging by mistake, Docker Compose cannot correctly parse the version. If you use the left double quote instead of the quote , the version that Docker compose will select will be '2' , not 2 , and therefore will not be able to equate it to the supported versions ( "2.0" , "2.1" , "3.0" ) . I would suggest changing it as follows:

version: "2"

Let me know if errors still persist.

+7
source

In your editor, instead of the usual ascii quotes, you enter smart quotes:

 version: "2" 

It should be:

 version: "2" 

I would recommend not writing yml files with this editor to avoid future problems.

+4
source

As indicated in the error logs, you should replace it with "2.0" instead of "2".

+1
source

The docker engine must match the file version. On the next page you can check which engine should be used, with which file format.

https://docs.docker.com/compose/compose-file/

enter image description here

0
source

Source: https://habr.com/ru/post/1268826/


All Articles