80

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?

Ajay
  • 2,241
Matt
  • 903

10 Answers10

127

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.

Artur Meinild
  • 31,035
DGIR
  • 1,386
30

I ran into the same problem today.

docker-compose down

It worked for me

7

..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"

muru
  • 207,228
5

You may need to remove the stopped container first.

$ docker ps -a | grep -i Exited

and try again with $ docker-compose up -d

It may caused by you didn't stop before recreating a container. The proper command sequence may look like this.

$ docker-compose down
$ docker-compose up -d
Leon
  • 51
3

I just ran into this too with docker-compose (V1), and I can't use the new docker compose (V2) right now in our stack as this answer suggests to do. All other hosts in our network were working fine, same docker-compose.yml and same docker and docker-compose versions except for one, that was throwing this KeyError: 'ContainerConfig'.

What worked for me using docker-compose (V1):

docker system prune --all --volumes
docker-compose up --detach

EDIT: Turns out another engineer ran docker compose up (V2) on this host so that is why I had my issue.

Elijah Lynn
  • 3,928
1

This worked clearly for me :

docker-compose down --volumes --remove-orphans
docker system prune --volumes --all -f

docker-compose build --no-cache docker-compose up --build

0

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: &quot;your path&quot;
    cmd: &quot;docker-compose build &amp;&amp; docker-compose up -d&quot;

0
sudo docker-compose rm -f
sudo docker-compose up

I used these commands to fix this error, but first, it's better to check if there are all the installed certificates and the docker itself.

NotTheDr01ds
  • 22,082
0

docker-compose v1 is long deprecated, but unfortunately Ubuntu does not yet ship v2. If you are feeling lucky, you can try to download the .deb file from Debian testing and install it, it worked fine for me.

quazgar
  • 170
0

This bug seems to stem from an old version of docker-compose, to upgrade install v2 with sudo apt-get install docker-compose-v2 and remove old version of docker-compose with sudo apt-get remove docker-compose

Pylinux
  • 401