Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version

Solution 1:

You are doing everything right and it should work. But there was a bug in docker-compose 1.11.0 which not recognized file format 3.1 as valid. (3.0 works).

There is already a new release of docker-compose (1.11.1) which includes the bugfix:

Bugfixes

Fixed a bug where the 3.1 file format was not being recognized as valid by the Compose parser

So I would recommend to upgrade your docker-compose version if you want to use file format 3.1.

At the moment the safest way to upgrade docker-compose is by deleting it and reinstalling it.

rm /usr/local/bin/docker-compose

Reinstall:

curl -L https://github.com/docker/compose/releases/download/1.11.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
docker-compose version 1.11.1, build 7c5d5e4

Now there isn't an error anymore on the file format. (I did not test with your .yml).

docker-compose up
Starting compose_a_1
Starting compose_b_1

Solution 2:

I have resolved the issue by upgrading docker-compose.

Follwed below steps to upgrade docker-compose in ubuntu16.04

step1:

$which docker-compose
/usr/bin/docker-compose

step2:

$sudo rm /usr/bin/docker-compose

step3:

curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose

step4:

chmod +x /usr/bin/docker-compose

Solution 3:

If your file version is 3.7 and you get the following error:

ERROR: Version in "./config.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") 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.

Here is the solution: -

(1) sudo apt-get remove docker-compose OR sudo rm /usr/local/bin/docker-compose

(2) sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

(3) sudo chmod +x /usr/local/bin/docker-compose

(4) sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

I hope this resolves the issue.