相关文章推荐
酒量小的薯片  ·  干货 | ...·  3 周前    · 
宽容的领带  ·  sql server ...·  1 年前    · 

Hello everyone.

I am try fairly new to docker and I am trying to set up an application using docker-compose (multi-container apps).

I installed the first version of the app and it was successful but I needed to add some configuration and changes some settings.

So I deleted the app service instance and tried to install again and it was successful.

The problem is that the app is still using the existing postgresql database. I have deleted the app service and started all over but the problem is still the same.

I tried to add docker-compose down --volumes

to the command script but can't find where to add.

Any help would be deeply appreciated.

Here is the sample docker-compose.yml

version: "3.8"
x-environment:
  &default-environment
  DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
  SECRET_KEY: 39dfb4c28e4
  PORT: 8080
  EMAIL_URL: smtp://email:password@smtp_url:port # https://glitchtip.com/documentation/install#configuration
  GLITCHTIP_DOMAIN: https://glitchtip.example.com # Change this to your domain
  DEFAULT_FROM_EMAIL: contact@example.com # Change this to your email
  CELERY_WORKER_CONCURRENCY: 2
  GLITCHTIP_MAX_EVENT_LIFE_DAYS: 10
  ENABLE_ORGANIZATION_CREATION: "False"
  # ENABLE_USER_REGISTRATION: "False"
x-depends_on:
  &default-depends_on
  - postgres
  - redis
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_HOST_AUTH_METHOD: "trust"
    restart: unless-stopped
    volumes:
      - pg-data:/var/lib/postgresql/data
  redis:
    image: redis
    restart: unless-stopped
    image: glitchtip/glitchtip
    depends_on: *default-depends_on
    ports:
      - "8080:8080"
    environment: *default-environment
    restart: unless-stopped
  worker:
    image: glitchtip/glitchtip
    command: ./bin/run-celery-with-beat.sh
    depends_on: *default-depends_on
    environment: *default-environment
    restart: unless-stopped
  migrate:
    image: glitchtip/glitchtip
    depends_on: *default-depends_on
    command: "./manage.py migrate"
    environment: *default-environment
volumes:
  pg-data:

The data in pg-data:/var/lib/postgresql/data remains in use even after deleting the app service.

Hello @Adebayo A. Asamu ,

I see you have another thread posted with same issue. I am adding the solution here as well for the benefit of the community.
The solution that worked for you is as follows:

You can also delete the volume via Azure portal or Azure CLI.
You can use a named volume instead of a host-mounted volume in your compose file to ensure that volume is deleted along with the deletion of the app service.
volumes:
  pg-data:
    name: pg-data
This will create a named volume, which is managed by Docker and will be deleted when the app service is deleted.
Please accept as answer and upvote if the above information has helped for the benefit of the community.