i have questions about docker-compose postgres:

image: healthcheck/postgres:alpine
environment:
  POSTGRES_USER: postgres



What is the default user of postgresql?
How does hardcoding the postgres user improve security?
What special rights does the postgres user have?
What is the upside and downside of using an unprivileged user in this scenario?
Is it necessary in our scenario to have an unprivileged user?
I searched for the healthcheck/postgres:alpine and I found the following repository with the Dockerfile:

https://github.com/docker-library/healthcheck/blob/master/postgres/Dockerfile.alpine

Assuming this is the correct repo for your docker image, the dockerfile specifies:

FROM postgres

COPY docker-healthcheck /usr/local/bin/

HEALTHCHECK CMD ["docker-healthcheck"]


So it extends the postgres docker image which is documented here:

https://hub.docker.com/_/postgres

Specifically for the password they mention the following:


  POSTGRES_PASSWORD This environment variable is recommended for you to
  use the PostgreSQL image. This environment variable sets the superuser
  password for PostgreSQL. The default superuser is defined by the
  POSTGRES_USER environment variable.
  
  Note 1: The PostgreSQL image sets up trust authentication locally so
  you may notice a password is not required when connecting from
  localhost (inside the same container). However, a password will be
  required if connecting from a different host/container...


Read the whole documentation at the image homepage.