no-version-key
The version key in docker-compose.yml is obsolete and ignored. Why Compose warns about it and how to migrate.
On this page
version: "3.8" at the top of a Compose file does nothing anymore. Compose v2 follows the unified Compose Specification and ignores the key entirely — recent versions print the attribute version is obsolete on every command. This rule flags Compose files that still declare it.
What the rule catches
version: "3.8"
services:
web:
image: nginx:1.27-alpineScanning this file reports:
⚠ WARN [docker-doctor/no-version-key]
The 'version' property is deprecated. Remove it to use standard Compose spec behavior.Why it matters
Beyond the warning noise, the key actively misleads: it suggests you're opting into a feature set, but the number has no effect — newer Compose features work regardless of what it says, so a reader trying to determine compatibility from version: "3.8" is reasoning from fiction. Removing the line loses nothing, silences the warning, and stops the file claiming something that isn't true.
How to fix it
The version key is obsolete in the Compose specification. Omitting it defaults to the latest specification.
services:
web:
image: nginx:1.27-alpineWhile updating, note the preferred filename is now compose.yaml (with docker-compose.yml kept for backwards compatibility), and the command is docker compose — the standalone docker-compose v1 binary is end-of-life.
Rule details
- Rule key —
docker-doctor/no-version-key - Category — Compose
- Default severity —
warning - Applies to — Docker Compose files
Explain this rule from the CLI:
npx @docker-doctor/cli@latest rules explain docker-doctor/no-version-keyChange its severity — or turn it off — in your config file:
// docker-doctor.config.ts
export default {
rules: {
"docker-doctor/no-version-key": "off",
},
};Severity affects the health score: error findings cost more points than warning, and info costs the least.