when I run docker-compose down without -v
or --volumes
, why my data is lost? Does docker delete my volume?
When I inspect the "docker volume inspect pgdata", it shows up always the current timestamp, looks like it is always recreated each time.
But when I just stopped the postgres container docker stop containerid and re-run the container, the data is still there.
version: '3.7'
services:
app:
container_name: bsf-quiz-app
image: sapkotasuren/bsf-quiz
ports:
- "443:8443"
depends_on:
- postgresqldb
postgresqldb:
image: postgres:latest
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=postgres
- POSTGRES_DB=bsfQuiz
volumes:
pgdata:
https://www.codepile.net/pile/YbkRvKEr
---updated 20/01/2021------------
I tried to do it on bind mount way, i see lot of data being created but still the same issue could not find the record which i have created before on the database, after docker-compose down and up.
I also tried to create named volume using docker command: docker create volume postgres, and mention it on my yaml file and set external to true. still the same issue!
yaml file can be found here: https://www.codepile.net/pile/MmbZkxmK
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…