Docker-compose giving 'ContainerConfig' errors after update today

Running Ubuntu server 22.04.4 LTS.

Today I did an apt update and apt upgrade which ran through a few updates, and then I pulled new docker images via docker-compose pull. After I tried to restart the containers via docker-compose, I got a bunch of errors regarding container config and many of the containers refused to start. Then when I run docker ps -a, I see a bunch of the container names have changed to include a random string of characters before the prior name (e.g. swag is now 5f6bfe94c235_swag). I didn’t change anything in the docker-compose.yml file and it had been working fine before this.

When I run sudo docker-compose up -d, I get the following output:

Traceback (most recent call last):
      File "/usr/bin/docker-compose", line 33, in <module>
        sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
      File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
        command_func()
      File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 203, in perform_command
        handler(command, command_options)
      File "/usr/lib/python3/dist-packages/compose/metrics/decorator.py", line 18, in wrapper
        result = fn(*args, **kwargs)
      File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1186, in up
        to_attach = up(False)
      File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1166, in up
        return self.project.up(
      File "/usr/lib/python3/dist-packages/compose/project.py", line 697, in up
        results, errors = parallel.parallel_execute(
      File "/usr/lib/python3/dist-packages/compose/parallel.py", line 108, in parallel_execute
        raise error_to_reraise
      File "/usr/lib/python3/dist-packages/compose/parallel.py", line 206, in producer
        result = func(obj)
      File "/usr/lib/python3/dist-packages/compose/project.py", line 679, in do
        return service.execute_convergence_plan(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 579, in execute_convergence_plan
        return self._execute_convergence_recreate(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 499, in _execute_convergence_recreate
        containers, errors = parallel_execute(
      File "/usr/lib/python3/dist-packages/compose/parallel.py", line 108, in parallel_execute
        raise error_to_reraise
      File "/usr/lib/python3/dist-packages/compose/parallel.py", line 206, in producer
        result = func(obj)
      File "/usr/lib/python3/dist-packages/compose/service.py", line 494, in recreate
        return self.recreate_container(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 612, in recreate_container
        new_container = self.create_container(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 330, in create_container
        container_options = self._get_container_create_options(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 921, in _get_container_create_options
        container_options, override_options = self._build_container_volume_options(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 960, in _build_container_volume_options
        binds, affinity = merge_volume_bindings(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 1548, in merge_volume_bindings
        old_volumes, old_mounts = get_container_data_volumes(
      File "/usr/lib/python3/dist-packages/compose/service.py", line 1579, in get_container_data_volumes
        container.image_config['ContainerConfig'].get('Volumes') or {}
    KeyError: 'ContainerConfig'

I’m able to manually start the containers by using the command:

sudo docker start <container_name>

Restarting the docker service and restarting the computer didn’t fix it. Any idea what broke with this update and how I can fix it?

Asked By: Matt

||

I ran into the same problem today.

docker-compose down

It worked for me

Answered By: Константин

Same here. After changing from docker-compose to docker compose it works with no other changes.

Now, my containers are running with:

docker compose up -d

instead of:

docker-compose up -d

This is because docker-compose is the V1 syntax, which is now deprecated. The V2 syntax is docker compose, since it’s now a plugin and not a separate command.

Answered By: DGIR

Sometimes you got this because you have running containers.
I got this error once with my ansible playbook and this works for me.

    - name: stopping existing container
      shell:
        chdir: "your path"
        cmd: "docker-compose down"

    - name: waiting 30 secondes to let the container stop
      ansible.builtin.pause:
        seconds: 30

    - name: deploy Docker Compose stack
      shell:
        chdir: "your path"
        cmd: "docker-compose build && docker-compose up -d"
Answered By: thierry14

..and if, like me, you were calling docker-compose via ansible then you’ll need to upgrade

community.docker.docker_compose:

to

community.docker.docker_compose_v2:

and possibly make some other changes that follow, e.g. I had to change "pull: true" to "pull: always"

Answered By: Jon Wilson
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.