Reputation: 1003
I have the following docker-compose.yml file
services:
containerA:
healthcheck:
test: "/build/docheck"
interval: "10s"
hostname: "containerA"
container_name: "containerA"
build:
dockerfile: "Dockerfile-5.6"
ports:
- "8081:8081"
version: "2.1"
When I try the following command: docker-compose up
it fails due to:
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 version of "2" (or "2.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/
I have the following setting:
$> docker-compose --version
docker-compose version 1.8.0, build unknown
$> docker --version
Docker version 17.12.0-ce, build c97c6d6
$> uname -r
4.9.0-4-amd64
$> lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch
I need to use version 2.1 because I am using the healthcheck. Any ideas why this is complaining?
Upvotes: 3
Views: 16515
Reputation: 1884
Compose files Version 2.1 are supported by Docker Compose version 1.9.0+. And you have docker-compose
version 1.8.0. To upgrade docker-compose
you can run following commands:
If installed via apt-get
:
sudo apt-get remove docker-compose
If installed via curl
:
sudo rm /usr/local/bin/docker-compose
If installed via pip
:
pip uninstall docker-compose
Then find the newest version on the release page at GitHub or by curling the API and extracting the version from the response using grep:
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')
Finally, download to your $PATH-accessible location and set permissions:
DESTINATION=/usr/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION
Upvotes: 4
Reputation: 4695
Installation of a new version of Docker Compose helped me to fix this error. See official documentation.
Upvotes: 0
Reputation: 21719
I was getting this error when I was trying the command docker-compose up
with the docker compose version 3. Then I run the command to check the docker version docker version
, which result the below output.
PS C:\SVenu\M4Movie\Api\Api> docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
So my version is 18.03, which is the latest one for now. So I moved to this link to check the compose file version which supports this engine. Then changed my docker compose version to 3.6.
version: '3.6'
Everything was working fine after that.
Upvotes: 1
Reputation: 1134
adding this because i ran into the same error on Ubuntu.
For me, it had nothing to do with my Compose
version despite what the error message says; i just had to run with sudo
. so
sudo docker-compose up
Upvotes: 3
Reputation: 263479
Following the link to details about versions, you'll find:
Version 2.1
An upgrade of version 2 that introduces new parameters only available with Docker Engine version 1.12.0+. Version 2.1 files are supported by Compose 1.9.0+.
https://docs.docker.com/compose/compose-file/compose-versioning/#version-21
You'll need to upgrade your docker-compose install to support the 2.1 file version. https://docs.docker.com/compose/install/
Upvotes: 1