Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose command deprecated, docker-compose up -d fails for Redis container; must first use docker-compose down #2196

Open
Debianer opened this issue Apr 6, 2024 · 5 comments
Labels
1. To develop docs examples Compose/Dockerfile/etc

Comments

@Debianer
Copy link

Debianer commented Apr 6, 2024

Problem

When using docker-compose up -d after using docker-compose pull (as per documentation) to upgrade containers, the setup stops working and containers don't come up. The main problem seems to be the Redis container throwing a bunch of error messages, more information below.

Solution/Workaround

Use the command docker-compose down before docker-compose up -d, as in:

  1. docker-compose pull
  2. docker-compose down
  3. docker-compose up -d

Pretty much the whole issue as well as suggested solutions are described here:

[Docker-compose giving 'ContainerConfig' errors after update today](https://askubuntu.com/questions/1508129/docker-compose-giving-containerconfig-errors-after-update-today)

I will copy and paste some stuff from the link, so people can find 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'

Alas, my attempt at fixing this problem using the new command "docker compose" without the hyphen resulted in a set of new volume folders for the persistent data, which were empty. The old ones were still there. Because "docker compose" uses a new syntax for creating names of volume folders.

So when moving from "docker-compose" to "docker compose", I guess everyone will either need to rename their folders for persistent data (does this actually work?) or change the yaml file to point to the exact locations. My configuration still mirrors the example. It currently looks like this:

  app:
    image: nextcloud:26-apache
    restart: always
    ports:
      - 8080:80
    volumes:
      - nextcloud:/var/www/html:Z
    environment:
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis

The resulting folder is named as such:

dockernextcloud_nextcloud

The "docker compose" command on the same yaml creates a new folder from scratch with this name:

docker_nextcloud_nextcloud

@tzerber
Copy link
Contributor

tzerber commented Apr 18, 2024

I believe all of the documentation + examples should be updated but this also means some files needs to be renamed. I've been using docker compose in place of docker-compose since docker put up the notices for the v1 syntax.
Compose nowadays use compose.yaml or compose.yml as filename, where everything here mentions docker-compose.yml and in very rare edge cases having docker-compose.yml as file can cause problems. It has been a while since i migrated from v1 to v2 but i don't remember having any data loss from that change, and the named volumes i had were working fine. The only imporant thing is to do docker-compose down before doing docker compose up -d (note the dashes in the command and the order of execution) and it should be fine.

@joshtrichards
Copy link
Member

Yeah I sort of mentally transitioned from docker-compose to docker compose so long ago that I don't even see the old references in the docs. :-)

There are issues with transitioning, which Docker documents here:

https://docs.docker.com/compose/migrate/

And there's a --compatibility flag that helps some:

https://docs.docker.com/compose/migrate/#migrating-running-projects

I've wanted to clean up the docs and drop all references docker-compose / docker-compose.yml (and related adjustments) but haven't because I hadn't been devoted enough to going back and thinking about how to convey the transition impact possibilities for those that have existing deployments (brought up with docker-compose et al). I saw @tzerber has been attempting some improvements in this area, but I haven't had the time to look those over myself.

@bean5
Copy link

bean5 commented Jul 18, 2024

@Debianer What is your docker compose version?

@Debianer
Copy link
Author

@Debianer What is your docker compose version?

docker -v

docker-compose version 1.29.2, build unknown

@bean5
Copy link

bean5 commented Sep 16, 2024

@Debianer That looks like an old version. I am at Docker Compose version v2.29.2.

Did you install docker using apt or perhaps by snap? I suggest using the manual install steps. I have had better success with it. If you are using debian or ubuntu, here are some links that might help. The instructions include how to remove older versions of docker and docker-compose.

Debian
https://docs.docker.com/engine/install/debian/

Ubuntu
https://docs.docker.com/engine/install/ubuntu/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. To develop docs examples Compose/Dockerfile/etc
Projects
None yet
Development

No branches or pull requests

4 participants