This is my sample docker-compose.yml file.

version: '2'
config-server:
  image: ccc/config-server
  restart: always
registration-server:
  image: ccc/registration-server
  restart: always
  ports:
    - 1111:1111

When I use docker-compose up -d I get an error:

"ERROR: The Compose file './docker-compose.yml' is invalid because:
Additional properties are not allowed ('registration-server', 'config-server' were unexpected)

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/

halfer's user avatar

halfer

20.4k19 gold badges109 silver badges202 bronze badges

asked Aug 2, 2016 at 9:45

Chintamani's user avatar

ChintamaniChintamani

1,16610 gold badges24 silver badges50 bronze badges

You are missing a services keyword, your correct .yml is:

version: '2'
services:
  config-server:
    image: ccc/config-server
    restart: always
  registration-server:
    image: ccc/registration-server
    restart: always
    ports:
      - 1111:1111

answered Aug 2, 2016 at 9:59

michael_bitard's user avatar

michael_bitardmichael_bitard

4,3221 gold badge28 silver badges38 bronze badges

1

This can also happpen if one of the keys is misspelled. In my case memory was spelled incorrectly:

After fixing it:

version: "3.8"
services:
  redis:
    image: redis:alpine
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 50M
        reservations:
          cpus: '0.25'
          memory: 20M

answered Jul 10, 2020 at 19:27

z atef's user avatar

z atefz atef

7,7373 gold badges60 silver badges54 bronze badges

In the This can also happen if, this can also happens if global level volumes is indented wrong, like not starting at column 0.

answered Sep 17, 2021 at 8:34

Fabien Haddadi's user avatar

1

use this for your docker-compose.yml

services:
  postgres:
    image: postgres:15-alpine
    ports:
      - 5432:5432
    environment: 
      POSTGRES_DB: webapp_dev
      POSTGRES_HOST_AUTH_METHOD: trust 

answered Aug 7, 2023 at 18:30

Victor Timi's user avatar

Victor TimiVictor Timi

4431 gold badge5 silver badges12 bronze badges

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.