docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.16k stars 1.13k forks source link

Writing files on external drive #1062

Closed thomaselmer closed 1 year ago

thomaselmer commented 1 year ago

I was trying to setup a Nextcloud instance with an Postgres database on a raspberry pi for a homelab. Therefore of course an external data drive is needed. Now I was able to reduce the problem to a permission failure. When trying to mount the external drive in the docker container for the _data directory I get an chown: changing ownership of '/var/lib/postgresql/data': Operation not permitted error. I also reduced the docker-compose to a simple command:

docker run -i -d -t --env=POSTGRES_PASSWORD=example -v /mnt/usb/db_data:/var/lib/postgresql/data postgres

Of course I tried to mount the drive in a simple ubuntu bash container:

docker run -i -t -v /mnt/usb:/opt/usb ubuntu /bin/bash

here I got all files, can write on it, etc

I hope this is the right place to ask and thank's for help

tianon commented 1 year ago

You need to make sure the filesystem of your storage is one that PostgreSQL supports and that the (unix) file permissions are suitable for the PostgreSQL instance to be able to read/write to it (I'm guessing it's something like vfat/FAT32, and PostgreSQL is probably not designed to handle that well).

Unfortunately, we do not have the bandwidth to provide in-depth integration/deployment/environment debugging or support here; these sorts of questions/requests would be more appropriately posted to a dedicated support forum, such as the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow.