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/
20.4k19 gold badges109 silver badges202 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_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
In the This can also happen if, this can also happens if global level volumes
is indented wrong, like not starting at column 0.
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
Explore related questions
See similar questions with these tags.