84

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,283
Matt
  • 973

10 Answers10

133

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,385
DGIR
  • 1,446
  • 10
    Upgrading to ubuntu 24.04 LTS can leave you in a state where docker-compose is broken and the v2 docker compose plugin isn't installed ( see bug ). On 24.04 LTS it can be installed with sudo apt-get install docker-compose-v2. – yoyoma2 Apr 26 '24 at 23:49
  • This worked for me on fedora :/ – Ariel Frischer Oct 20 '24 at 05:35
  • 3
    Don't forget to remove docker-compose from your system, otherwise you might run into this issue again and forget why it's not working, and need to debug it all over again. I totally didn't do that. – leetNightshade Oct 26 '24 at 06:51
30

I ran into the same problem today.

docker-compose down

It worked for me

  • Be careful, if you have a local development DB this command can remove its data, so you have to set it up again from scratch – jgosar Mar 22 '24 at 12:20
  • worked for me as well. I've made some changes to my compose file, manually stopping and removing one of the containers from the docker-compose file using the docker command instead of just running down. – Krystian Nov 06 '24 at 20:49
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,970
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
  • My KeyError: 'ContainerConfig' was exaclty this problem. Using tool (open-balena-admin/scripts/compose up) to do docker compose up i don't pay attention that i had exited container. So run open-balena-admin/scripts/compose down solve my problem. #balenaos #openbalenaadmin – AndreaT Jan 27 '25 at 10:29
4

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,938
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;

  • You're still using docker-compose, which is no longer a supported syntax for Docker Compose - See here. – Artur Meinild Mar 22 '24 at 12:42
  • yes I know but it works for me. I'm using docker-compose 3. You can use docker compose down as well. it's equivalent Just remove all the existing container and run it again. – thierry14 Mar 23 '24 at 21:17
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,381
  • 1
    Welcome to Ask Ubuntu! "We're a little bit different from other sites."

    Your answer could be improved with additional supporting information. If possible, please

    [edit]

    your post to add further details, such as explanations or documentation, so that others can understand how to solve the problem. You can find more information in How do I write a good answer? - "Brevity is acceptable, but fuller explanations are better." It might be helpful to review some highly upvoted answers as examples to follow. Thanks!

    – NotTheDr01ds Aug 07 '24 at 11:42
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Aug 07 '24 at 11:46
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