# Fix "the attribute `version` is obsolete" in a Docker Compose File

Yes. An agent removes the obsolete version key, proves the resolved configuration is identical, and updates the old-format keys that sit beside it.

[Run this on Rush](https://cloud.getrush.ai/run/fix-compose-version-obsolete-warning/docker-compose/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

Compose v2 prints this on every command: `the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion`. The warning is honest about the first half. The top-level `version` key no longer selects a file format, so deleting it changes nothing. The agent does not ask you to take that on trust. It runs `docker compose config`, which prints the fully resolved project, before and after removing the line and compares the two outputs. In a project like simonw/django-sql-dashboard, whose `docker-compose.yml` begins with `version: "2"` and defines three services (`app`, `docs` and `db`), the two outputs are the same, and that comparison goes in the pull request.

The second half of the job is what the warning does not mention. A file that still says `version: "2"` was written for an older Compose, and the same resolved output shows which of its other keys now mean something different from what the author had in mind. Here the `app` service has `links: - db`. The author needed it so the Django container could reach Postgres by the name `db`. Compose now puts every service of a project on one default network where service names resolve, so the link is not needed for that. But the resolved configuration shows that `links` still does one thing: Compose turns it into a `depends_on` entry for `db` with `condition: service_started` and `restart: true`. Delete the link as dead syntax and the start order goes with it.

So the agent replaces `links` with an explicit `depends_on` instead of deleting it, and checks with `config` again that the `app` service resolves to the same dependency. The check earns its place here: the familiar list form, `depends_on: - db`, resolves without `restart: true`, so the agent writes the long form with both fields. It then reads how the project waits for the database, because start order is not readiness. This one sets `entrypoint: ["./test_project/wait-for-postgres.sh"]`, a script that loops on `psql $DATABASE_URL -c '\q'` once a second until the server answers. That works and the agent leaves it alone. In the pull request it notes the alternative the current format allows, which the old one in this file did not: a `healthcheck` on `db` and `condition: service_healthy` on the dependency.

Finally it checks the commands people are told to type. `docs/contributing.md` in this repository says `docker-compose build`, `docker-compose run app` and `docker-compose down -v`, the hyphenated v1 command, whose older releases are the ones that needed a `version` key before they would accept a `services` block. The agent does not rewrite your documentation uninvited. It reports the lines, and says which minimum Compose release a file with no `version` requires, so the reviewer can decide whether the docs change in the same pull request. Where it can, it also brings the stack up once to confirm the services start: the sandbox has no Docker, so it installs `docker.io` with apt, starts `dockerd`, and downloads the Compose v2 binary from the project's releases, since that package does not include the `docker compose` plugin.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Docker Compose prints \"the attribute `version` is obsolete, it will be ignored\" for this repository. Find every Compose file (docker-compose.yml, compose.yaml, override and per-environment files). Your sandbox has no Docker: install docker.io with apt and start dockerd, and download the Docker Compose v2 binary from its GitHub releases, because the apt package has no `docker compose` plugin. For each file, save the output of `docker compose config` and the warning, remove the top-level version key, run config again and diff the two resolved outputs; they must be identical apart from paths. Then list every key in the file that comes from the old 2.x or 3.x formats and what the resolved configuration turns it into: links, volumes_from, mem_limit and cpu_shares, deploy.resources, depends_on in its list form. Replace links with an explicit depends_on that resolves to the same dependency, including its condition and restart fields, and confirm it with config. Do not remove a key whose resolved effect would be lost. Do not change images, ports, environment values or scripts. Bring the project up once and report which services became healthy or exited. Search the README, docs, Makefile and CI workflows for the hyphenated docker-compose command and list each place without changing it; say which Compose version a file without a version key needs. Open a pull request with the before and after config diff.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that deletes one line from `docker-compose.yml` and replaces the `links` block on `app` with `depends_on`. The description has three pieces of evidence: the warning as Compose printed it, an empty diff between the resolved configuration before and after the `version` line was removed, and the `depends_on` section of the resolved `app` service before and after the `links` change, showing the same `db` entry both times. If the stack was started, the service states follow.

The reviewer checks that the empty diff really is the whole resolved file and not a fragment, and reads the list of places that still say `docker-compose`. In this repository that is a dozen lines of `docs/contributing.md`. The description also carries the note about replacing the wait script with a health check, as a suggestion with the two snippets it would take, so the reviewer can ask for it in a follow-up without having to work out the syntax.

## Run it on every repository with a Compose file

The warning shows up in every repository at once when a team's Docker installation updates, so this is usually a sweep. From your own script, send the request once per repository, with that repository as the `resources` URL and a `request_id` that is a new UUID per repository so a retry does not start a second run. Runs beyond the key's concurrency limit are created `queued` and start as earlier ones finish.

To keep it from coming back in new repositories, add an automation on the Project with a `github` trigger on `pull_request.opened` and a prompt that checks changed Compose files for a `version` key or `links`. Mark that automation read only, so its runs comment on the pull request and push nothing.

## Why run it on Rush?

Deleting one line is easy, and that is the trap: the same edit session tends to delete `links` too, because every answer about this warning calls it legacy. Whether that is safe depends on what Compose resolves the key to today, and the only way to know is to ask Compose. The agent runs `config` on each variant in a sandbox, keeps the outputs, and bases each edit on a diff instead of on a rule of thumb about file formats.

For a sweep across many repositories the proof matters more than the edit. Each pull request arrives with its own before and after resolved configuration, so a reviewer who has never seen that service can approve it by reading an empty diff. Starting the stack in the sandbox, where a port clash or a leftover volume cannot affect anyone, adds the one check a static comparison cannot make.

## Frequently asked questions

### Is it safe to delete the version line?

With Compose v2, yes: the key is read and ignored, which is what the warning says. The agent shows it by diffing `docker compose config` before and after. The only risk is a teammate or a CI image still running an old `docker-compose` v1 release, which is why it lists every place that command appears.

### Do I still need links?

Not for name resolution. Services in one Compose project share a default network and reach each other by service name. `links` does still imply a dependency: Compose resolves it to a `depends_on` entry that starts the linked service first and restarts the dependent one with it. Replace it with a `depends_on` that says the same, unless the two services genuinely can start in any order.

### Can I just silence the warning?

Running Compose with `--log-level error` hides it, along with every other warning Compose would print, including ones about variables that are not set. Removing the key is a one-line change with no effect on the resolved project, so it is cheaper than working around it.

### Will it rename docker-compose.yml to compose.yaml?

No. Compose still reads `docker-compose.yml`, and a rename touches every script and document that names the file. If you want the rename, ask for it in the prompt and the agent updates the references it finds in the same pull request.

## More Docker Compose jobs

- [Harden Docker Compose Services with Read-Only Filesystems and Dropped Capabilities](https://getrush.ai/run/harden-compose-services/docker-compose/)
- [Pin and Upgrade Container Images in Docker Compose](https://getrush.ai/run/pin-image-versions/docker-compose/)
- [Add Smoke Tests to a Docker Compose Stack](https://getrush.ai/run/write-compose-smoke-tests/docker-compose/)

## More jobs like this: Fix a bug from an alert

- [Fix "Configuration via mocha.opts is DEPRECATED" and the --opts error on Mocha 8 and later](https://getrush.ai/run/fix-configuration-via-mocha-opts-is-deprecated/mocha/)
- [Fix "Copy Plugin has been initialized using an options object that does not match the API schema"](https://getrush.ai/run/fix-copy-plugin-options-does-not-match-the-api-schema/copy-webpack-plugin/)
- [Fix "Could not find method compile() for arguments" in Gradle 7 and Later](https://getrush.ai/run/fix-could-not-find-method-compile/gradle/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
