Unsupported Compose file version: 1.0 , even when I have the right compatability settings

I am trying to stack deploy.

> docker stack deploy -c docker-compose.yml name
unsupported Compose file version: 1.0

These are my settings

> docker-compose version
docker-compose version 1.6.0, build d99cad6
docker-py version: 1.7.0
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1j 15 Oct 2014


> docker version
Server: Docker Engine - Community
 Engine:
  Version:          19.03.0-beta3

I meet the compatibility requirements, specified here https://github.com/docker/compose/releases/tag/1.6.0

Note that Compose 1.6.0 requires Docker Engine 1.9.1 or later, or 1.10.0 if you're using version 2 of the Compose File format (see the changelog below).

Why isn't this working?


Solution 1:

I encountered this error while using a command to preprocess docker-compose.yml file in order to use variable interpolation with docker stack deploy command.

Command :
docker compose -f docker-compose.swarm.yml config | docker stack deploy --compose-file - stackname

Error :
unsupported Compose file version: 1.0

This is caused by docker compose -f docker-compose.swarm.yml config command not outputing the "version: '3.8'" line from my docker-compose file for some reasons so it falls back to '1.0'


Quick workaround :
(echo -e "version: '3.8'\n"; docker compose -f docker-compose.swarm.yml config) | docker stack deploy --compose-file - stackname

Solution 2:

The docker stack deploy command supports any Compose file of version “3.0” or above. If you have an older version, see the .....

source