Home > Net >  Docker: Version "4.7.0" in ".\docker-compose.yml" is invalid
Docker: Version "4.7.0" in ".\docker-compose.yml" is invalid

Time:04-10

Since Docker has put up the new update for 4.7.0, I am getting the error above. This is my docker-compose.yml:

version: "20.10.14"

services:
  postgres:
    environment:
      POSTGRES_PASSWORD: xxxx
      POSTGRES_DB: marketplace
      POSTGRES_USER: postgres
    build:
      dockerfile: ./dbdockerfile/Dockerfile
  football_marketplace:
    build:
      dockerfile: Dockerfile
    ports:
      - 3300:3300
    depends_on:
      - "postgres"
  reactjs:
    build:
      dockerfile: ./football_marketplace-app/frontend/Dockerfile
    ports:
      - 3000:3000

I updated docker to 4.7.0 and tried multiple version numbers as a subsitute. I tried 20.10.14, which is the client version. Ive tried 4.7.0 and a couple other numbers.

This is my docker version output:

Client:
 Cloud integration: v1.0.23
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:53:11 2022
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.7.0 (77141)
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:46:14 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I have read other threads on here about this error but most suggest something that went wrong with docker-compose.override.yml which I don't use at all. Or that the docker version doesn't match the version number in the docker-compose.yml, but mine does.

CodePudding user response:

The version in the compose file is 2.x, 3.x, or in the latest compose-spec, removed completely:

https://docs.docker.com/compose/compose-file/#version-top-level-element

If you want to support legacy environments (many of them will still exist since compose-spec is relatively new), then use 2.4 which was the latest 2.x. The 3.x versions were focused on Swarm Mode support and removed some features like build and depends_on that do not work in Swarm Mode.

  • Related