coolify: [Bug]: On each redeploy new volume is created

Description

For each redeploy of an app - new volume is created. I use docker compose app with mentioned volume

volumes:
  store:
    driver: local

It creates a new volume for each redeploy: Screenshot 2024-06-07 at 14 53 28

It does not see storage in storages: Screenshot 2024-06-07 at 14 54 37

Minimal Reproduction (if possible, example repository)

Create docker compose service with storage -> redeploy it

Exception or Error

No response

Version

v4.0.0-beta.294 Latest

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 25 (6 by maintainers)

Most upvoted comments

I have the same problem. Not figured out how exactly it reproduces yet, but every day my data is being lost after some of redeploys. I use postgres and docker-compose with a volume.

Developer note (for confirmed bugs). Reproduction steps:

  1. Follower these steps: https://github.com/coollabsio/coolify/issues/2376#issuecomment-2434581604

@renatoaraujoc Wow, thanks for this find. This solves the issue for me.

EDIT: Forget what I said, I was just stupid. Changed the postgres image of one of my services to make use of backups and in this process did not change the volume mapping path. Setting pg-data:/var/lib/postgresql/data solved the issue. Layer 8 (user) problem šŸ˜†

@andrasbacsai I can confirm that predefined volumes aren’t working, I’m on version v4.0.0-beta.360.

I’m trying to deploy the predefined app Grafana with Prometheus, but I want to use my predefined volumes and not the auto-generated ones.

Print screens are as follows: Screenshot 2024-10-19 at 11 49 42

Resolved docker-compose for grafana service: Screenshot 2024-10-19 at 11 52 22

Resolved volumes for this docker-compose: Screenshot 2024-10-19 at 11 50 58

external: true does not work as well Screenshot 2024-10-19 at 12 00 36

UI: Screenshot 2024-10-19 at 11 52 34

Am I doing something wrong?

EDIT

I found a hackish way to make this work! The problem is at this line:

https://github.com/coollabsio/coolify/blob/5d62a46a16f252e6ece4d25fe56838e99883d91b/bootstrap/helpers/shared.php#L1767C51-L1767C62

From that code, when Coolify sees ā€œdriver_opts.typeā€ as ā€œcifsā€, it just returns the volume as is and exclude any dynamic created volume, so this will work (also you must tell that the volume is external!):

volumes:
  internal-grafana:
    name: internal-grafana
    external: true
    driver_opts:
      type: cifs

Will resolve to:

services:
  grafana:
    image: grafana/grafana-oss
    volumes:
      - 'internal-grafana:/var/lib/grafana' # the abcde1234-internal-grafana:/var/lib/grafana will disappear!

I have the same problem. Some templates like dragonfly let me set a volume name and the data is persistent across restarts. Other templates or pure docker compose deployments set a random string in front of the volume name. I tried setting volume names in the docker compose, but that did not work.

Volumes:
  gitea_data:
    drivers: local
  gitea_config:
    driver: local
  postgresql_data:
    driver: local

or

volumes:
  gitea-data:
    name: gitea_data
    driver: local
  gitea-timezone:
    name: gitea_timezone
    driver: local
  gitea-localtime:
    name: gitea_localtime
    driver: local
  postgresql-data:
    name: postgresql_data
    driver: local

When I pull a new image and restart the containers, I get a new random string in front of the volume names and the old volume is lost.

I still can’t fix this. The volumes are being lost on each redeploy.

My docker-compose.yaml volumes are:

volumes:
  project_db_data:
    name: project_db_data

I noticed similar bug that kinda relates to this, so I won’t open new issue yet.

Issue / bug: Coolify is not adding dynamic name for the volumes. This creates problems when deploying multiple services with identical Docker Compose files on a single server, as they both attempt to use the same volume.

In documentation it says that each volume should get dynamic name. But that is not the case. (At least when deploying with docker compose) ā€œTo prevent storage overlapping between resources, Coolify automatically adds the resource’s UUID to the volume name.ā€ Persistent Storage - Coolify Docs

Example fo docker-compose.yaml where this happens. When deploying this twice, both pocketbase containers tries to use same volume pb_data

services:
  sveltekit:
    build:
      context: ./sveltekit
      dockerfile: Dockerfile
    environment:
      NODE_ENV: production
    depends_on:
      - pocketbase

  pocketbase:
    build:
      context: ./pocketbase
      dockerfile: Dockerfile
    environment:
      GO_ENV: production
    volumes:
      - pb_data:/home/nonroot/app/pb_data

When creating new resource using previous docker-compose file, coolify just adds this to it. No dynamic tag.

volumes:
  pb_data:
    name: pb_data