Reputation: 2880
I'm trying to set up my docker project name, and according to documentation there should be the docker compose file top-level property 'name' to do so, but I can't figure out how to use it.
I found references at the end of The Compose application model section and in the specific Name top-level element section, but none of the two have an example and I still get an error when trying to run docker-compose up -d
version: "3.3"
name: "project-name"
services:
# ...
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid top-level property "name". Valid top-level sections for this Compose file are: version, services, networks, volumes, secrets, configs, and extensions starting with "x-".
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/
Upvotes: 3
Views: 2255
Reputation: 263469
To use the compose-spec, you need a tool that parses that spec (like docker compose
with a space) and you shouldn't be specifying a version. If you are parsing the file with an older version of docker-compose
or a tool that doesn't use the spec, these newer fields won't work and you'll likely see it fall back to version 1 without a version field.
With version: "3.3"
, that expects the format defined in the version 3 documentation.
Upvotes: 2