apk update
apk add postgresql
Then change /etc/postgresql/postgresql.conf
listen_addresses = 'localhost' # what IP address(es) to listen on;
to
listen_addresses = '*' # what IP address(es) to listen on;
Change /etc/postgresql/pg_hba.conf
by adding line after
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md5
replace the net 0.0.0.0/0
with the trusted nets. You can add more host entries. Also see https://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
https://www.cyberciti.biz/faq/howto-add-postgresql-user-account/
CREATE DATABASE jerry;
GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
ALTER USER 'tom' WITH PASSWORD 'new_password';