<< Remove device mappers from disk | Home | Build Urho3D on arm-device >>

mount postgres data-folder on NFS

I struggled for some time getting postgres to run on docker/k8s with /var/lib/postgresql/data mounted on an nfs-server.

I reguallary ended up with

chown: changing ownership of '/var/lib/postgresql/data/base/**/**': Operation not permitted.

I'm no expert in nfs and its export-options but to make the story short I stumbled over a stackoverflow-entry that suggested to change the postgres-docker-image's uid/gid to the one that has write access of the NFS-folder.

Ok,...you need to create a new docker image for this, but finally. Thx to 'Eddie Parker' my Dockerfile ended up like this. Where my user has the uid 1000 and is in group 100:

Dockerfile

FROM postgres:11.2
ENV TZ=America/Los_Angeles

# Make us the same gid/id as the nfs mount.
RUN sed -i 's/:999:/:1000:/g' /etc/group
RUN sed -i 's/:999:999:/:1000:100:/g' /etc/passwd

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

Once you have this create a new image:

sudo docker build -t nfs/postgres:11.2 .

PS: I guess it would be fine to create a user with UID:999 gid:999 on the NFS-System which creates the data-directory.

Export this post as PDF document  Export this post to PDF document

Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!
Home