Postgresql settings in pg_hba.conf and 'occ maintenance:install'?

The manual says:

The default configuration for PostgreSQL (at least in Ubuntu 14.04) is to use the peer 
authentication method. Check /etc/postgresql/10/main/pg_hba.conf to find out which 
authentication method is used in your setup.

I tried several settings but none is working.
I added the following line

local   nextcloud       www-data                                peer

so the linux user www-data can access the postgres db nextcloud without password.
But running occ maintenance:install fails

sudo -u www-data php /var/www/nextcloud/occ  maintenance:install  --database pgsql --database-host "/var/run/postgresql" \
--database-name nextcloud  --database-table-prefix oc_ --database-user nextcloud  \
--database-pass "" --admin-user admin --admin-pass JejV9RYQUI5o250PQJyJZesAOQKgJguv \
--data-dir /var/nc-data

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] FATAL:  Peer authentication failed for user "nextcloud"

Does anyone knows a working setup?

P.S.:

From the Postgresql manual:

peer
Obtain the client’s operating system user name from the operating system and check if it matches the requested database user name. This is only available for local connections.

Have you tried to use www-data as username for the nextcloud-database (also in the occ command)?