Docker Compose KeyError: ContainerConfig: Migrate from docker-compose v1
If docker-compose up ends with KeyError: 'ContainerConfig', inspect the command and traceback before changing the Compose YAML. The well-known failure is associated with the legacy Python Compose v1 path, often visible as docker-compose with a hyphen and a compose/service.py traceback. Docker has retired Compose v1 and directs users to the Go-based docker compose plugin.
Check the two commands side by side:
docker-compose versiondocker compose versionIf the failing command reports Compose 1.x, migrate the CLI first. Do not run docker compose down -v as a reflex: the -v option removes volumes and can delete the data you were trying to preserve.
Confirm which Compose is actually running
The command spelling is evidence:
| Command | Typical implementation | Meaning for this error |
|---|---|---|
docker-compose | Legacy standalone Python binary | The path implicated by the official Compose issue showing ContainerConfig |
docker compose | Docker CLI plugin using the current Compose line | The supported migration target |
| A wrapper or system service | Could call either binary | Inspect the script, CI image, or service definition rather than your interactive shell |
Docker’s retired products documentation says Compose v1 is no longer maintained and has been superseded by Compose v2. The Compose history also distinguishes the CLI version from the Compose Specification, so a top-level version: field in the YAML is not the same thing as the installed CLI version.
Migrate to the current docker compose command
Use the installation method appropriate for the host: current Docker Desktop bundles Compose, while Linux installations can use the Docker CLI plugin. After installing, verify the binary before touching the project:
docker compose versiondocker compose config --quietThen run the same project with the space-separated command:
docker compose pulldocker compose up -ddocker compose config --quiet validates the rendered model without starting the services. If it reports an environment or syntax problem, fix that output separately; it is not the ContainerConfig traceback.
For a CI runner or server, check all execution paths:
rg -n --hidden --glob '!node_modules' 'docker-compose|docker compose' .Search deployment scripts, systemd units, Makefiles, cron entries, and CI workflows. A local shell can use v2 while a scheduled job still invokes the old hyphenated binary.
Recreate containers without deleting volumes
The Compose issue that popularized this traceback shows a Python Compose 1.29.2 process failing while it tried to read old container volume metadata after an image update. Once the CLI is migrated, recreate the project state in a controlled order:
docker compose psdocker compose config --servicesdocker compose downdocker compose up -dThe plain down command removes the project containers and network but keeps named volumes unless you explicitly ask for volume removal. Before any destructive cleanup, record the project name, volume names, and backup status:
docker volume lsdocker compose config --volumesdocker compose ps -aIf an orphaned container from an earlier project definition is the actual problem, review the list first and then use --remove-orphans deliberately:
docker compose up -d --remove-orphansDo not add -v unless you have confirmed that every project volume is disposable or backed up. Removing a container is not the same as removing the database stored in its named volume.
If v2 still fails, follow the new inner error
Moving from v1 should remove the specific Python ContainerConfig path. If docker compose still fails, do not keep repeating the old fix. Capture:
docker versiondocker compose versiondocker compose configdocker compose ps -aThen classify the new failure:
- a rendered variable is empty: check the Compose interpolation inputs and
--env-fileboundary; - a service starts before its dependency is ready: add a real healthcheck and
service_healthycondition; - an image cannot be pulled or recreated: inspect the image reference, registry credentials, and container logs;
- a volume cannot be mounted: inspect the host path and the user running Docker.
The existing Compose interpolation guide covers variables that are empty during parsing. For a database that is created before it is ready, use the Compose healthcheck guide instead. Those are different boundaries from a retired CLI traceback.
Keep the migration reproducible
Once the project starts under Compose v2, make the command part of the repository workflow rather than relying on developer memory:
- Document the minimum Docker Desktop or Compose plugin version that the project actually tests.
- Use
docker composein scripts and CI. - Run
docker compose config --quietbefore an automated deployment. - Keep named-volume backup and restore steps separate from container recreation.
- Record the output of
docker compose versionwhen an upgrade changes behavior.
The takeaway is that KeyError: 'ContainerConfig' is usually a CLI compatibility signal, not a request to delete application data. Identify the legacy docker-compose path, migrate to docker compose, and only then clean up the specific stale containers that remain.
FAQ
Does changing docker-compose.yml to compose.yaml fix ContainerConfig?
No. The filename can be modernized, but the traceback is primarily about the Compose CLI and the container metadata path. Check whether the command is still the retired Python docker-compose binary.
Can I run docker compose down -v to clear the error?
Only when you have confirmed that every project volume is disposable or backed up. -v removes volumes, so it can destroy database data. Migrate the CLI and try a plain down first.
Why does docker-compose work on one machine but fail after a Docker upgrade?
Compose v1 is no longer maintained and can depend on container metadata behavior that changes with the Docker Engine. The official Compose issue shows this class of failure with a Python v1 traceback; use Compose v2 for the supported compatibility path.
References:
Docker Docs: Retired Docker Compose v1
Docker Docs: History and development of Docker Compose
Report a typo or broken link, or suggest a related topic.