Do you need to put the version at the top of docker-compose.yml file?

I have got what I hope is not a total newb question. When starting a new project, how do you tell what versions to put at the start of a docker-compose.yml file? When I look at the Use Docker Compose documentation, the examples given don’t include a version at the start of the file. Also, the examples at Awesome Compose don’t include a version. However, just about every other example I find online seems to give a version. When I try googling for the lasted version, I only seem to get documentation that has a warning that this page contains information on the legacy versions. Am I missing something here or do you no longer need to put the version at the start of a docker-compose.yml file, and if you do, how do you tell what is the latest?

Also on Awesome Compose compose.yaml is used instead of docker-compose.yml. Is there a reason to uses one over the other?

Docker compose v2 (the cli plugin) doesn’t require the version anymore, in fact it ignores it and always uses the latest schema. It also favors the filename compose.yml over docker-compose.yml. Though, you can use both, and even have both in the same folder.

I missed it yesterday, but you posted your topic in the category “Tips & Howtos”, which is used if you want to share “Tips & Howtos” with the community, not to ask for them.

I moved your topic to Compose subcategory of Open Source Projects category.

Thank you for the info