878 words
4 minutes

Docker Compose KeyError: ContainerConfig: Migrate from docker-compose v1

2026-08-18
DevOps
Docker
/
DevOps
/
Containers
/
Troubleshooting

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:

Terminal window
docker-compose version
docker compose version

If 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:

CommandTypical implementationMeaning for this error
docker-composeLegacy standalone Python binaryThe path implicated by the official Compose issue showing ContainerConfig
docker composeDocker CLI plugin using the current Compose lineThe supported migration target
A wrapper or system serviceCould call either binaryInspect 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:

Terminal window
docker compose version
docker compose config --quiet

Then run the same project with the space-separated command:

Terminal window
docker compose pull
docker compose up -d

docker 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:

Terminal window
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:

Terminal window
docker compose ps
docker compose config --services
docker compose down
docker compose up -d

The 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:

Terminal window
docker volume ls
docker compose config --volumes
docker compose ps -a

If an orphaned container from an earlier project definition is the actual problem, review the list first and then use --remove-orphans deliberately:

Terminal window
docker compose up -d --remove-orphans

Do 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:

Terminal window
docker version
docker compose version
docker compose config
docker compose ps -a

Then classify the new failure:

  • a rendered variable is empty: check the Compose interpolation inputs and --env-file boundary;
  • a service starts before its dependency is ready: add a real healthcheck and service_healthy condition;
  • 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:

  1. Document the minimum Docker Desktop or Compose plugin version that the project actually tests.
  2. Use docker compose in scripts and CI.
  3. Run docker compose config --quiet before an automated deployment.
  4. Keep named-volume backup and restore steps separate from container recreation.
  5. Record the output of docker compose version when 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

Docker Compose issue #11742: KeyError: 'ContainerConfig'

Docker Docs: docker compose CLI reference

Docker Compose KeyError: ContainerConfig: Migrate from docker-compose v1
https://laplusda.com/en/posts/docker-compose-keyerror-containerconfig/
Author
Zero
Published at
2026-08-18
License
CC BY-NC-SA 4.0
Was this article useful?

Report a typo or broken link, or suggest a related topic.