'Deploy mariaDB and nextcloud via Docker with a mariaDB error message

I have a question about nextcoud, mariaDB and Docker.

Initial situation: I have a Synology NAS and would like to install mariaDB and nextcloud via Docker.

I found a tutorial here: https://mariushosting.com/synology-how-to-install-nextcloud-using-docker/

As in the tutorial I also use portainer.

Here is my configuration in compose file format:

version: '2.9'

services:
  
  mariadb:
    container_name: mariadb
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - mariadb:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - MYSQL_PASSWORD=mysqlpassword
      - MYSQL_DATABASE=nextcloudatabasename
      - MYSQL_USER=nextclouduser

  nextcloud:
    container_name: nextcloud
    ports:
      - 40010:80
    links:
      - mariadb
    environment:
      - PUID=1024
      - PGID=100
      - TZ=Europe/Berlin
    volumes:
      - /volume1/docker/nextcloudStable/html:/var/www/html
      - /volume1/docker/nextcloudStable/custom_apps:/var/www/html/custom_apps
      - /volume1/docker/nextcloudStable/config:/var/www/html/config
      - /volume1/docker/nextcloudStable/data:/var/www/html/data
      - /volume1/docker/nextcloudStable/themes:/var/www/html/themes/
    image: nextcloud
    restart: always

volumes:
  mariadb: # nextcloud

After deployment I also get the installation page of nextcloud under IP of NAS: http://192.168.1.10:40010/

I entered mariadb as host and get the following error message:

Error while trying to create admin user: 
Failed to connect to the database: An exception occurred in driver: 
SQLSTATE[HY000] [1045] Access denied for user 'nextclouduser'@'172.17.0.7' (using password: YES) 

Could someone please explain me why the error occurs and how I can fix it.

Thanks a lot



Solution 1:[1]

below works for me just do it as a stack in portainer

version : '3.8'

volumes:
  nextcloud:
  db:
  
services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed

    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_PASSWORD=passt
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      
      
  cloud:
      image: nextcloud
      restart: always
      ports:
        - 8888:80
      links:
        - db
      volumes:
        - nextcloud:/var/www/html
      environment:

      - MYSQL_PASSWORD=pass
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hasnto