Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Docker Compose "the attribute `version` is obsolete, it will be ignored": what the warning means and when to remove the line

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Docker Compose prints a warning that ends "the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion" when a compose file still begins with a line such as version: "3.8". It is a warning, not a failure, and the value is not used. Deleting the line is the fix for Compose v2, but check first that nothing else reads the same file with an older tool.

What the warning means

Docker's documentation says the top-level version property "is defined by the Compose Specification for backward compatibility" and that it is "only informative", with a warning that it is obsolete if used. It adds: "Compose always uses the most recent schema to validate the Compose file, regardless of the version field."

The history page explains why. Compose v1 is the Python tool, invoked as docker-compose; its projects typically carry a version from 2.0 to 3.8 that refers to a file format. Compose v2 is written in Go and invoked as docker compose. The page says: "Unlike v1, Compose v2 ignores the version top-level element in the compose.yaml file and relies entirely on the Compose Specification to interpret the file." It calls Compose v2 and v5 the supported versions, and says the Compose Specification "makes the version top-level element optional".

The same page lists the old file formats the value used to select: format 1 with Compose 1.0.0 in 2014, which lacks a top-level services key; format 2.x with Compose 1.6.0 in 2016; and format 3.x with Compose 1.10.0 in 2017. It says 2.x and 3.x "were merged into the Compose Specification", which is rolling. A value such as 3.8 therefore names a format that Compose v2 no longer treats as a separate choice. The separate top-level name element sets the project name and is not a replacement for version.

In the compose-go v2.4.4 source, the loader checks each file it reads. If the file has a version key, it prints the message with the file's path in front, then deletes the key before building the project; the deletion, like the warning, happens only when validation is on. A project that loads three files, each with version, therefore prints three warnings, one per file path. The reading also shows the warning appears only when validation is on, so a tool that loads files with validation skipped may not print it.

Nothing in the page or the source says the warning changes the exit status or the containers. It tells you the line does nothing.

Likely causes

Cause What you see How to confirm
The main compose file still has a version line One warning naming that file grep -n '^version' compose.yaml
Override or included files also have it One warning per file, each with its own path Compare the paths in the warnings with the files in the project
An old template or tutorial was copied The line holds a value such as 3.8 The value is one of the 2.x or 3.x formats from Compose v1
The same file is used by Compose v1 (the Python tool) on another host The warning appears on v2 hosts only Run that host's own docker-compose version output; the pages give no way to tell v1 from v2 by the command name
The file is deployed to a swarm The deploy command accepts versioned files docker stack deploy appears in a script or pipeline

Prove the cause before changing anything

Everything here only reads.

1. Which Compose runs. The reference page says docker compose version shows the version information:

docker compose version --short

The page says --short shows only the version number. A version number beginning with 2 or 5 means Compose v2 or v5, the supported releases. The warning text lives in the Go loader of Compose v2, and Compose v1 is the Python tool. A host whose docker-compose command is the Python tool is Compose v1; the pages give no way to tell the two apart from the command name, so run that host's own version output before assuming.

2. Which files carry the line.

grep -n '^version' compose.yaml compose.override.yaml

A line number and value for a file means that file is the cause (this finds the usual unindented form of the key). No output means the warning comes from another file named in the message.

3. Does anything else deploy the same file? Search scripts, pipelines and cron jobs for docker-compose (with the hyphen) and docker stack deploy. The docker stack deploy page says "The deploy command supports Compose file version 3.0 and above". The page does not say what happens to a file with no version, so a file that a pipeline deploys to a swarm needs a decision from whoever owns the pipeline, not a quiet edit.

4. Record what Compose will build. docker compose config renders the data model that Compose applies, merging the files and resolving variables. Save it now:

docker compose config > config-before.yaml

Removing version should leave this output unchanged, because the loader discards the key before it builds the model. That reading is the test used in the confirm step. The saved model holds resolved values, including any passwords or keys that arrive from an .env file or the environment, so keep it owner-only and delete it only after the confirm step, which still compares against it.

Fix

The change below applies only where the cause is confirmed and the search in step 3 found no other tool reading the file.

First save the current state:

cp -p compose.yaml compose.yaml.2026-12-02
docker compose config > config-before.yaml

Risk: the next edit deletes the top-level version line from the compose file. A slip in the edit, such as deleting the line after it, changes the stack the next docker compose up creates. Where Compose v1 or docker stack deploy also reads the file, Docker's pages do not say what they do without the line.

Delete the version: ... line in your editor and save the file. Our own advice: editing the file does not change running containers; the next docker compose up reads the new file.

To undo it: copy the saved file back, then confirm the output matches the saved model.

cp -p compose.yaml.2026-12-02 compose.yaml
docker compose config > config-restored.yaml
diff config-before.yaml config-restored.yaml

For each other file named in a warning, the same four parts apply with its own name. For compose.override.yaml, first save it:

cp -p compose.override.yaml compose.override.yaml.2026-12-02

Risk: the next edit deletes the top-level version line from the override file; a slip in the edit changes the stack the next docker compose up creates.

Delete the version: ... line in that file and save it.

To undo it: copy the saved override file back, then confirm the output matches the saved model.

cp -p compose.override.yaml.2026-12-02 compose.override.yaml
docker compose config > config-restored.yaml
diff config-before.yaml config-restored.yaml

Example (illustrative): On docker01, /srv/app/compose.yaml and /srv/app/compose.override.yaml both begin version: "3.8". docker compose version --short prints a version number beginning with 2, so Compose v2 runs. Each docker compose command prints two warnings, one per file path. A search of the repository's scripts finds no docker-compose and no docker stack deploy. The administrator saves both files and the output of docker compose config, deletes the line from each file, and runs docker compose config > config-after.yaml. diff config-before.yaml config-after.yaml prints nothing, docker compose config --services still lists web and db, and the warnings are gone.

Confirm the fix

  1. docker compose config --services lists the same services as before and prints no warning.
  2. docker compose config > config-after.yaml followed by diff config-before.yaml config-after.yaml prints nothing. The config page documents --services as printing the service names, one per line.
  3. The next planned docker compose up creates the services that docker compose config --services listed.

What to watch afterwards

  • New files copied from old guides bring the line back. Add a search for ^version: to the checklist for compose files.
  • Where other hosts run docker-compose v1 or docker stack deploy, keep their files separate or decide the format with their owners before a shared edit.
  • A warning that names a path you do not recognise can mean an included file or an override file in another directory.

Risks and limits

  • These commands have not been run or lab-tested.
  • The message text is a reading of compose-go v2.4.4; other releases may word or print it differently.
  • Docker's pages give no statement on what Compose v1 does with a file that has no version line, so a v1 host needs its own test.
  • Docker's docker stack deploy page gives no statement for files without version.
  • The warning is harmless; removing the line is a tidy-up, not a repair. Skip it where a second tool shares the file and its behaviour is unclear.

Sources