I have been trying to persist my database in a postgres container but when I delete the container and map a new container to the volume only the text files persist but database disappears.
docker volume create pg_data
docker run -d -p 5432:5432 --mount type=volume,source=pg_data,target=/app postgres
upon exec -ing into the conatiner I created a text file in app and a test Databaase .
Upon deleting this container and running a new container with the exact same command as above, Only the text file persisted but database was not.
Can anyone explain why this is happening and how can I persist my database ?