Hello everyone.
I am fairly new to docker and I am trying to deploy a multi-container app to azure app service using
docker-compose.yml
I was able to successfully deploy the app.
I deleted the app service instance and tried deploying the app again and it was successful but the problem now is that the database from the first deployment was not deleted and the second deployment is now using the database.
Here is sample docker-compose.yml configuration
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:
I have removed and re-installed the app multiple times, but the volume is not deleted.
Any help will be appreciated.
Thank you.
When you delete an Azure App Service instance, it will delete the resources associated with it, but it will not delete any persistent data associated with the app. In the case of your Docker Compose configuration, the volumes section specifies that a volume named pg-data should be used to store data for the postgres container. This volume is not deleted when you delete the App Service instance, so the data stored in it will persist across deployments.
To ensure that the volume is deleted when you delete the App Service instance, you will need to remove the volume manually. You can do this by running the following command:
docker volume rm pg-data
You can also delete the volume via Azure portal or Azure CLI.
Alternatively, 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.
Thank you for the speedy response @Dimple Rane
The second solution worked.
Regarding your first solution, how do I run this? The challenge is connecting to the app service to run the command.
The app is being run on a Linux app service plan and I tried connecting via SSH but I keep getting 'SSH CONN CLOSED'