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.

Introduction & Quick Summary
WARN[0000] /srv/app/docker-compose.yml: the attribute `version` is obsolete,
it will be ignored, please remove it to avoid potential confusionCompose 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 theversion: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 content | Compose v2 behavior | Compose v1 behavior |
|---|---|---|
No version | Spec mode, all features | Error: version is required |
version: "3.9" | Warning, ignored | Format 3.9 |
version: "2.4" | Warning, ignored | Format 2.4 |
version: "1" | Warning, unsupported semantics | Legacy format 1 |
| Unknown top-level key | Error (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"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"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-levelconfigsandnameare optional top-level keys. - Unknown top-level keys are errors in v2 (
additional properties 'version' not allowedappears if--strictor a schema-aware linter is used). docker composereadscompose.yaml,compose.yml,docker-compose.yamlanddocker-compose.ymlin that order;COMPOSE_FILEoverrides.
Key Comparison Table
| Concern | Compose v1 | Compose v2 |
|---|---|---|
| Binary | docker-compose (Python) | docker compose (plugin, Go) |
| Schema selection | version: key | none, always spec |
depends_on conditions | 2.x only | supported |
profiles | not supported | supported |
Top-level name | not supported | supported |
docker compose config | config in v1.25+ | available |
| Migration friction | Symptom | Resolution |
|---|---|---|
Old docker-compose in CI | "Unsupported config option" or ignored keys | Upgrade to the v2 plugin |
| Warning treated as failure | CI job fails on WARN | Remove version, or filter the line |
version in one of several -f files | Warning names that file | Remove from all of them |
| Version 1 file | No services key | Rewrite into the spec format |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Case 1: Removing the line safely
-version: "3.8"
-
services:
db:
image: postgres:17Only 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.
docker compose config -q # silent success
docker compose up -d
docker compose logs -f dbCase 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:
# .github/workflows/ci.yml
- name: Validate compose file
run: docker compose config --quiet 2>/dev/nullThe 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 versionCase 3: Features that never existed in the declared version
version: "3.7"
services:
web:
image: nginx
depends_on:
db:
condition: service_healthyIn 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.1Precedence 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
docker compose -f docker-compose.yml -f docker-compose.override.yml configversion 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:
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
versionfrom a v1-only environment.docker-composethen fails withVersion in "./docker-compose.yml" is unsupportedorversion is required. - Removing
versionbut keeping v1-only syntax.links,extendswithfile:in v3 style, ordeployunder 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 obsoletetothe attribute \version` is obsolete, it will be ignored, and matching on the exact string in CI filters is fragile; matchobsoleteor use--quiet`. COMPOSE_IGNORE_ORPHANSand 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, sox-common: &commonis fine whereversionis 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 documentationThe Docker documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Docker guides
All Docker guidesDocker build: failed to compute cache key: not found
BuildKit cannot hash a file that is not in the context. Correct the context path, the .dockerignore rules, or the COPY source and stage name.
Docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock
An endpoint mismatch, a stopped daemon, or a missing socket mount. Resolve which of the three, then start, retarget, or mount.
Docker Compose: bind: address already in use and Port Conflicts
A published port is a host socket, and two projects cannot own it. How to find the real owner, why an override file merged instead of replacing, and how.
Docker Buildx: Building Multi-Architecture Images (AMD64 & ARM64) Explained
One tag, several architectures: the driver that supports it, QEMU versus cross-compilation, registry cache, and reading the manifest list.
More in Docker
All Docker guidesThe guides filed next to this one in Docker, in library order.