2

I try to run a Postgres Docker container in an Azure Web App. When i try to mount a volume to the Data folder, i get the error: FATAL: data directory "/var/lib/postgresql/data" has wrong ownership

my Compose script:

version: "3"
services:
  db:
    image: postgres:11.2
    environment:
      - POSTGRES_USER=test
      - POSTGRES_PASSWORD=test
      - POSTGRES_DB=test
    volumes:
      - ${WEBAPP_STORAGE_HOME}/data:/var/lib/postgresql/data
    ports:
      - "5433:5432"

Docker host is set to linux.

how can i get around this issue? (if i dont, the data is lost every restart / container update)

5
  • did you follow this guide? learn.microsoft.com/en-us/azure/app-service/containers/…
    – silent
    Jun 15, 2020 at 10:01
  • also, allow me the question if a WebApp is the best way to run postgres?! Have you thought about using the Azure-managed postgresql service?
    – silent
    Jun 15, 2020 at 10:06
  • azure-managed postgres is an option, if i cannot get it to work. Also Azure Container Service is an option, but the problem is still the same as above.
    – Stefan S
    Jun 15, 2020 at 10:37
  • @StefanS Were you able to run it inside an Azure web app ? Sep 3, 2020 at 17:28
  • @RajatArora Unfortunatly not, you need to have a Disk attached -> i ended up with using Kubernetes (AKS)
    – Stefan S
    Sep 8, 2020 at 7:17

1 Answer 1

0

For this issue, you can take a look at the Dockerfile of the image postgres. There is a step that changes the ownership of the directory /var/lib/postgresql with the command:

chown -R postgres:postgres /var/lib/postgresql

But when you use the persistent storage in Azure Web App, you cannot change the permission of it. So it causes the error:

FATAL: data directory "/var/lib/postgresql/data" has wrong ownership

See more details about the limitation here.

4
  • so there is no solution?
    – Stefan S
    Jun 16, 2020 at 8:53
  • @StefanS If you use the AKS, then you can try the persist volume with the disk. It's a solution.
    – Charles Xu
    Jun 16, 2020 at 8:58
  • ok sure, this is a solution! can you point me to a startingpoint (docu or sth)?
    – Stefan S
    Jun 16, 2020 at 9:25
  • @StefanS Yeah, you can take a look at the persist volume with the disk.
    – Charles Xu
    Jun 17, 2020 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.