3

tell me how can I store PostgreSQL database data in an Azure Storage account. The PostgreSQL deploy to Azure Container Instance. When I restart the Azure Container instance all data disappears. Dockerfile

FROM timescale/timescaledb:latest-pg12

ENV POSTGRES_USER=admin
POSTGRES_DB=dev-timescaledb
POSTGRES_PASSWORD=password
PGDATA=/var/lib/postgresql/data/pgdata

CMD ["postgres", "-c", "max_connections=500"]

Command for creating a Container Instance and mounting a Storage Account

az container create --resource-group test-env --name test-env --image test-env.azurecr.io/timescale:latest --registry-username test-env --registry-password "registry-password" --dns-name-label test-env --ports 5432 --cpu 2 --memory 5 --azure-file-volume-account-name testenv --azure-file-volume-account-key 'account-key' --azure-file-volume-share-name 'postgres-data' --azure-file-volume-mount-path '/var/lib/postgresql/data'

but i got an error

data directory “/var/lib/postgresql/data/pgdata” has wrong ownership The server must be started by the user that owns the data directory.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39

1 Answers1

2

It caused by an existing issue that you cannot change the ownership of the mount point when you mount the Azure File Share to the Container Instance. And it cannot be solved currently. You can find the same issue in SO. I recommend you use the AKS with the disk volume and it will solve the problem for Postgres on persisting data.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39