27

I am running docker-compose build in a folder with the relevant docker files and yml files. I see the following error

root@ubuntu187_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker-compose build
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 (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.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

The docker-compose.yml is as follows

# Basic IDOL container setup
# Uses nifi to ingest and index data into content
# Uses find to make search results available
# Default admin user is created for find in the community service
#  - see community/run_community.sh for details

version: "3.7"

x-args-shared:
  - &idol-version IDOL_VERSION=12.4.0 # version of IDOL components to use

# Change the IP to the address of an external IDOL LicenseServer instance
x-external-licenseserver-host: &external-licenseserver-host
  - "idol-licenseserver:xx.xx.xx.xx"

# Shared volume configuration for nifi and view service - see volumes
x-idol-ingest-volume: &idol-ingest-volume
  - idol-ingest-volume:/idol-ingest

#x-idol-categorisation-volume: &idol-categorisation-volume
#  - idol-categorisation-volume:/idol-categorisation

# Shared volume in NiFi and View
# Any files dropped into this volume will be ingested and indexed
volumes:
  idol-ingest-volume:
# idol-categorisation-volume:

services:
  idol-content:
    image: idol-compose/content
    build:
      context: ./content
      args:
        - *idol-version
    extra_hosts: *external-licenseserver-host
    ports:
      - 9100:9100

docker-compose version

root@ubuntu18_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker-compose -version
docker-compose version 1.17.1, build unknown

docker version

root@ubuntu18_demo_2:~/IDOLDockerContainers_12.4.0_COMMON/basic-idol# docker -v
Docker version 19.03.1, build 74b1e89

I can't change the version on the docker-compose.yml file.

Vinay Joseph
  • 5,515
  • 10
  • 54
  • 94

6 Answers6

23

I have resolved the issue using following steps

$ sudo apt-get remove docker-compose
$ 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
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
  • 1
    Location `/usr/local/bin/` (seems) has mayor prevalence over `/usr/bin/` so symbolic link would not be necessary. Verified with `$ export | grep PATH | egrep "/usr/bin|/usr/local/bin"` and `$ whereis docker-compose`. Needed to open new terminal after download to take effect. Ubuntu 20.04.1 here. – Mauricio Dec 10 '21 at 00:20
  • for update to 3.8 version use 1.29.2 curl. – reza_khalafi May 16 '22 at 06:20
  • This gave me `/usr/bin/docker-compose: line 1: Not: command not found` when I tried to run `docker-compose up`, using the latest version `2.6.1` instead of `1.23.2` at the time of writing. You need to install it without a version instead, then it works - I thought. See [Docker-compose: /usr/local/bin/docker-compose : line 1: Not: command not found](https://stackoverflow.com/questions/58747879/docker-compose-usr-local-bin-docker-compose-line-1-not-command-not-found). I only later read further in the link and found that you just need the `v` in front of the version, like `v2.6.1`. Untested. – questionto42 Jul 14 '22 at 14:00
  • Find the latest release at the [docker compose github repo](https://github.com/docker/compose) on the right of the page. – questionto42 Jul 14 '22 at 14:04
  • Now at present, the command can be: sudo curl -L "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose – c2j Jun 03 '23 at 09:09
19

Your compose is too old, if you cannot change the version in compose, try to upgrade to latest docker-compose version

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

Detail refers to this

atline
  • 28,355
  • 16
  • 77
  • 113
7

The spec was updated in Compose v1.27 to merge the properties from version 2.x and 3.x compose files into a single format. The version property can still be included for legacy reasons but is no longer required and can be omitted if running the latest release of docker-compose.

The following script will update your installation on Ubuntu and solve the issue :

#!/bin/bash
sudo apt-get remove docker-compose 
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Besworks
  • 4,123
  • 1
  • 18
  • 34
  • 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 (e.g "2.2" or "3.3") || thank you for this solution! @syedasadrazadevops – SyedAsadRazaDevops Aug 29 '22 at 07:02
1

Using "sudo" the command works for me.

sudo docker-compose up
SFARPak
  • 49
  • 4
  • 2
    Using `sudo` is totally unnecessary and will not help with OP's problem. Please do not advise people to use `sudo` without a good reason (which running containers is not) – helvete Dec 01 '21 at 14:31
0

I did the following steps:

sudo apt-get remove docker-compose
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
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

I hope this will resolve this issue.

Felipe Plets
  • 7,230
  • 3
  • 36
  • 60
S.Kihara
  • 191
  • 2
  • 2
0

Docker now officially supports compose so according to the documentation https://docs.docker.com/compose/install/compose-plugin/#install-using-the-repository use sudo apt-get install docker-compose-plugin then docker compose.

If you use sudo apt-get install docker-compose then docker-compose then you will end up with the older tool not supporting the newest format.

Utopiah
  • 306
  • 1
  • 11