My changes were lost in new Docker container

UPDATE

I was wrong. The entrypoint just appends a line, it will not reset the file, but it is on a volume so when you commit the container, that will not be committed ince that is not part of the container.

The rest of my old answer is correct. You should not change the file, but use POSTGRES_HOST_AUTH_METHOD, but the bets if you don’t trust in every host without a password unless you are just testing on your local computer.

My original answer is below

The entrypoint overwrites that file every time you start the container. Please read the description of that image for solutions and more details

Quote:

POSTGRES_HOST_AUTH_METHOD

This optional variable can be used to control the auth-method for host connections for all databases, all users, and all addresses. If unspecified then scram-sha-256 password authentication is used (in 14+; md5 in older releases). On an uninitialized database, this will populate pg_hba.conf via this approximate line:

echo "host all all all $POSTGRES_HOST_AUTH_METHOD" >> pg_hba.conf

You shouldn’t do that. The right way is to use a Dockerfile and create a custom image so every change is documented and you can rebuild the image everywhere.