Question: Why is the /var/lib/postgresql/data directory cleared when mounting /var/lib/postgresql as volume? #1165
larsderidder
started this conversation in
General
Replies: 1 comment
-
It's probably getting cleared because it's marked as a "volume" in the image metadata, so the container runtime is likely creating a new mount underneath it on every container startup if you didn't specify one explicitly. To solve the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We had an issue in our Azure K8S deployment using this image, where restarting the pod caused the database to be recreated. Upon further inspection it turned out that the
/var/lib/postgresql/data
directory was recreated every time the pod was restarted.Normally when using this image, I mount a volume directly on
/var/lib/postgresql/data
, but in this case the pod mounted/var/lib/postgresql
. The reason for this was that mounting/var/lib/postgresql/data
on Azure gives an error, as Azure volumes have alost+found
file on the root of the mount point, and then Postgres complains that the data directory isn't empty and it cannot initialize the database.Anyway, I just don't understand why this wouldn't work. Any files created directly in
/var/lib/postgresql
are persisted on restart. I solved it now by setting thePGDATA
env variable to/var/lib/postgresql/pgdata
, and that directory is properly persisted. I looked at theinit_db.sh
script but didn't see any reason for it to wipe the/var/lib/postgresql/data
directory.What is the reason that specific directory is cleared?
Beta Was this translation helpful? Give feedback.
All reactions