Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Docker Compose: the version attribute is obsolete

Compose v2 ignores the version key and warns on every command. Remove it, unless a Compose v1 client still reads the file and needs a schema.

~5 min readDocker
#Docker#Compose#YAML#CLI
A Docker Compose file crate with a crossed-out version tag, a cyan spec gate and an amber services card beside it

Introduction & Quick Summary

text
WARN[0000] /srv/app/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion

Compose v2 reads the Compose Specification, which has no version key. The line is parsed, ignored, and reported so that people stop copying it. Nothing about the file is broken: containers start normally and the warning appears on every command that reads the file, including docker compose config, up, ps and down.

What to do depends on which Compose binaries actually run your file:

  • Only Compose v2 (docker compose) or newer — delete the version: line. That is the whole fix.
  • A mix with Compose v1 (docker-compose) — v1 needs a version to select a schema. Keep it until every client is upgraded, and accept the warning in v2.
  • Third-party tools that parse the file themselves — some IDE plugins, migration tools and older CI images still expect version. Check them before removing it from a shared repository.
File contentCompose v2 behaviorCompose v1 behavior
No versionSpec mode, all featuresError: version is required
version: "3.9"Warning, ignoredFormat 3.9
version: "2.4"Warning, ignoredFormat 2.4
version: "1"Warning, unsupported semanticsLegacy format 1
Unknown top-level keyError (strict schema)Usually ignored

Core Mechanics, Signatures & Reproducible Setup

Docker Compose v1 was a Python program that dispatched on version to pick a schema and translation layer: 1, 2.x and 3.x each had different capabilities. Compose v2 is a Go plugin built on the Compose Specification, a single schema that absorbed the union of those formats, so the selector is meaningless.

Reproduce the warning in an empty directory:

# docker-compose.yml version: "3.9" services: api: image: nginx:1.27-alpine ports: - "8080:80"
bash
docker compose config # WARN[0000] /tmp/demo/docker-compose.yml: the attribute `version` is obsolete, ... # name: demo # services: # api: ...

Removing the line produces the same rendered config with no warning:

services: api: image: nginx:1.27-alpine ports: - "8080:80"
bash
docker compose config --quiet && echo "compose file is valid"

docker compose config is the canonical check: it resolves extends, profiles, interpolation and environment defaults, then prints the normalized model. --quiet turns it into a validator suitable for CI, and it exits non-zero on a real schema error while the obsolete-attribute warning stays a warning.

Compile-level facts that matter when editing:

  • The current schema requires services; networks, volumes, secrets, file-level configs and name are optional top-level keys.
  • Unknown top-level keys are errors in v2 (additional properties 'version' not allowed appears if --strict or a schema-aware linter is used).
  • docker compose reads compose.yaml, compose.yml, docker-compose.yaml and docker-compose.yml in that order; COMPOSE_FILE overrides.

Key Comparison Table

ConcernCompose v1Compose v2
Binarydocker-compose (Python)docker compose (plugin, Go)
Schema selectionversion: keynone, always spec
depends_on conditions2.x onlysupported
profilesnot supportedsupported
Top-level namenot supportedsupported
docker compose configconfig in v1.25+available
Migration frictionSymptomResolution
Old docker-compose in CI"Unsupported config option" or ignored keysUpgrade to the v2 plugin
Warning treated as failureCI job fails on WARNRemove version, or filter the line
version in one of several -f filesWarning names that fileRemove from all of them
Version 1 fileNo services keyRewrite into the spec format

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Case 1: Removing the line safely

diff
-version: "3.8" - services: db: image: postgres:17

Only remove the key and the blank line that followed it; YAML indentation for services stays at column zero. A common accident is deleting services: instead, which yields top-level object must be a mapping rather than a warning.

bash
docker compose config -q # silent success docker compose up -d docker compose logs -f db

Case 2: CI still runs Compose v1

Ubuntu 20.04 images and some Debian packages install Compose 1.29 as docker-compose. If a pipeline depends on it, keep version: "3.9" in the shared file and silence the warning where v2 runs:

bash
# .github/workflows/ci.yml - name: Validate compose file run: docker compose config --quiet 2>/dev/null

The better fix is to stop shipping two clients: install the plugin, alias the old command, and delete version once the image is rebuilt.

# install the v2 plugin in CI DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} mkdir -p $DOCKER_CONFIG/cli-plugins curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 \ -o $DOCKER_CONFIG/cli-plugins/docker-compose chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose docker compose version

Case 3: Features that never existed in the declared version

version: "3.7" services: web: image: nginx depends_on: db: condition: service_healthy

In v1, file format 3.x dropped the long-form condition, so this file was invalid despite looking modern. v2 accepts it. Removing version is what makes the file honest — the declared schema never supported the feature.

The same applies to profiles, extends across services with depends_on, and deploy.resources limits, which behave differently between v1 formats.

Case 4: Project name instead of version

People sometimes keep version because they confuse it with naming. The project name has its own key in v2:

name: acme-staging services: api: image: ghcr.io/acme/api:2.1

Precedence is -p flag, COMPOSE_PROJECT_NAME, top-level name, then the directory name. In v1 only the flag, the environment variable and the directory applied.

Case 5: Multiple compose files in one command

bash
docker compose -f docker-compose.yml -f docker-compose.override.yml config

version in any of the merged files triggers the warning for that path, and a version in the override does not change the merged schema — merges are structural, not version-aware. Remove the key from every file in the set:

bash
grep -rn '^version:' --include='compose*.y*ml' --include='docker-compose*.y*ml' .

Case 6: Tools that still parse version themselves

OrbStack, Podman Compose, kompose, Renovate's Docker Compose manager and some IDE plugins read the file directly. Podman's podman-compose accepts the spec but older releases keyed behavior off version. When a repository is shared, check the toolchain list in the README before deleting the key; if a tool needs it, pin the file to "3.9" and document why rather than leaving it unexplained.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Treating the warning as an error. Exit status stays 0 for this warning; only a real schema violation fails docker compose config.
  • Deleting version from a v1-only environment. docker-compose then fails with Version in "./docker-compose.yml" is unsupported or version is required.
  • Removing version but keeping v1-only syntax. links, extends with file: in v3 style, or deploy under v1 behave differently; the spec is more permissive, not identical.
  • Compose v2.20 through v2.2x wording. The message changed from the attribute version is obsolete to the attribute \version` is obsolete, it will be ignored, and matching on the exact string in CI filters is fragile; match obsoleteor use--quiet`.
  • COMPOSE_IGNORE_ORPHANS and other env toggles. They do not suppress schema warnings; only removing the key does.
  • YAML anchors and x- extensions. Extension fields are valid top-level keys in the spec, so x-common: &common is fine where version is not.

Paste an edited compose file into the Compose validator to see the merged services, ports and volumes before running it, and use the YAML validator when a warning turns into a parse error after an edit. The env reference helps confirm that variables referenced in the file are actually set.

Primary references: the Compose Specification documents the version top-level element as obsolete and lists the valid keys, and the Compose file FAQ covers how v1 formats map onto the spec.

Official references

primary documentation

The Docker documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Docker guides

More in Docker

All Docker guides

The guides filed next to this one in Docker, in library order.