You have to configure posgresql config file;
Add this line to pg_hba.conf
host all all 0.0.0.0/0 md5
Also you can define specific config file for psql in docker like that;
command: -c config_file=/etc/postgresql.conf