docker-library/docs

Writing on external device

thomaselmer opened this issue · 1 comments

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_stick/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_stick:/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

This is just the general Docs repository for all official images. To get help with a specific image, then you'd need to follow the "where to get help" links. For nextcloud, here is their help links:

Where to get help:
the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow

- from Docker Hub readme

If you think there is an issue with the image, you could also try their github issues:

Where to file issues:
https://github.com/nextcloud/docker/issues

from later in the Docker Hub readme


For postgres, I'd point out the arbitrary user section (and point you to the same "Where to get help" or check previous issues in docker-library/postgres).

Basically, the /var/lib/postgresql/data folder must be owned by the process running initdb, so either the folder given to the container is allowed to be chowned to the container postgres user (perhaps being blocked by seccomp?), or you have to run the image as the non-root owner of the folder (/mnt/usb_stick/db_data). Or even chown the folder from the host to the container postgres user (id 999 in Debian based images) and then start the container.