why do you want to change the default port of mariadb?
all you need for a setup you’ll find in the example docker compose files on github.
so it’s more or less set this three env variables for the images mariadb and nextcloud:apache. But this example is named unsecure. no https/ssl.
MYSQL_PASSWORD=
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud