My docker-compose file:
version: '3'
services:
app:
container_name: application
build: .cloud/php
image: app-application
depends_on:
- pgres
ports:
- "9050:9000"
volumes:
- ./:/var/www:cached
networks:
- application_network
nginx:
container_name: application.nginx
image: nginx
ports:
- "8050:8000"
volumes:
- .cloud/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:cached
- ./:/var/www:cached
depends_on:
- app
networks:
- application_network
pgres:
container_name: application.postgres
image: postgres
restart: always
ports:
- "54325:5432"
environment:
POSTGRES_DB: application
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
PGDATA: /tmp
volumes:
- .cloud/postgres/data:/var/lib/postgresql/data
networks:
- application_network
networks:
application_network:
driver: bridge
When I run docker-compose down, postgresql data is not persisting and database resets completely. I tried to put the postgresql volume into its own /postgresql/data folder but still same result. What am I missing here?
PGDATA. If you don't understand it, I would remove it. On Docker Hub they're suggesting to define it as a subdirectory of/var/lib/postgresql/data. I also looked at thedocker-entrypoint.shbut didn't quite understand how they're using that env variable..cloud/postgres/data:/tmpinstead of.cloud/postgres/data:/var/lib/postgresql/data.