nextcloud / docker

⛴ Docker image of Nextcloud
https://hub.docker.com/_/nextcloud/
GNU Affero General Public License v3.0
5.81k stars 1.8k forks source link

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

Open Debianer opened 3 months ago

Debianer commented 3 months ago

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 commented 2 months ago

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 commented 4 weeks ago

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.