A way to set postgres UID in docker-compose

I notice that postgres:12-alpine likes to run as UID 70 . There are a number of ways to tweak it to run as an arbitrary UID but given the way the docker-compose.yml is set up for TT-RSS I found an easy fix.

Adding the following to the db service will replace the postgres user in the /etc/passwd file with the UID and GID from the .env file.

entrypoint: ["sh", "-c", "sed -e '/^postgres/s=^postgres:x:[0-9]*:[0-9]*:=postgres:x:${OWNER_UID}:${OWNER_GID}:=' -i /etc/passwd; sed -e '/^postgres/s=^postgres:x:[0-9]*:=postgres:x:${OWNER_GID}:=' -i /etc/group; exec docker-entrypoint.sh postgres"]

Setting the user in the postgres Docker image is an ongoing discussion, the latest of which can be found in the GitHub issue docker-library/postgres#709

I’d be happy to submit this as a PR; my Gogs Username is the same as my forum username tszabo.

you could’ve just asked for the post to be moved if you can’t do it yourself, no need to post three times about it (and flag it for whatever reason :confused:) .

anyway, no, i’m not going to add this pointless and very ugly hack to the repository. it largely doesn’t matter which UID the application in this (third party!) container is running under anyway, i’m not even going to ask why it’s such a pressing matter for you to customize it.

if you want to have this properly configurable, the right thing would be contacting whoever publishes postgres container and asking them to add this.

Sorry, will do next time. I think it was because my account was too new.

In any case I run multiple services on the same host all dockerized and I like my stacks to run under the same UID - but I fully understand not updating the default docker-compose.yml to use this workaround.

There’s actually ongoing discussion about how to deal with this upstream. Indeed it makes sense for this project to wait for it to be solved upstream and use the solution there.