I'm encountering issues mounting the File share of my Azure Storage Account into my Azure Container App running a Postgres image, with the goal of making the data in the container persistent. I can successfully mount the File share, and I can see the files within the container. However, when attempting to mount the File share to the Postgres directory, I'm facing permission problems. Found a similar question here but it is 3 years old and does not relate to Azure Container Apps in particular:
Deploying Postgres database on azure Container Instance?
I've noticed that when using the PGDATA env variable to set the data directory of the database to /fish for example in the container, the permissions change slightly from postgres:postgres to postgres:root.
I suspect that the mount point is owned by the root user, whereas the database requires it to be owned by the postgres user. How can I resolve this permission mismatch to ensure a successful mount into the Postgres directory within the Azure Container App? Any insights or guidance on adjusting ownership or handling permissions would be greatly appreciated.
How can I resolve this permission mismatch? Any ideas for a fix or work around are welcome.
Logs:
initdb: error: could not change permissions of directory "/fish": Operation not permitted
The files belonging to this database system will be owned by user "postgres".
chmod: /fish: Operation not permitted
initdb: error: could not change permissions of directory "/fish": Operation not permitted
The files belonging to this database system will be owned by user "postgres".
chmod: /fish: Operation not permitted
This is the normal permissions reminder from initdb. So, use a named volume instead of a bind volume.
version: "3"
services:
db:
image: postgres:11.2
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test
- POSTGRES_DB=test
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "5433:5432"
This will create a named volume that is not mounting a location from your host system and causing the permissions to go wrong. For more information, you can refer to the links below: