CodePark/ questions / Docker Compose
START PRACTICINGPRACTICE
Backend question · Docker › Docker Compose

An old tutorial starts the Compose file with version: "3.8" and runs docker-compose up. What is true for current Docker Compose v2?

Compose v2 is run as docker compose, and the top-level version key is obsolete and ignored

Compose v2 is run as docker compose, and the version key is obsolete. Compose v2 is a plugin for the Docker CLI. It follows the Compose Specification, where version is no longer used. If the key is there, Compose only prints a warning.

"The
version key is required and decides which features are available" is wrong for this reason. "You must set version: "4" to use depends_on conditions" is also wrong: features such as depends_on conditions don't depend on any version number. "Files without version are treated as the old v1 format" is wrong too, because Compose v2 ignores the key.