Database Setup step - Docker - MYSQL always Connection refused

Hello,

I am trying to install matomo (last version) over docker. Currently, matomo stops always by step three Database Setup with the error:

Error while trying to connect to the database server: SQLSTATE[HY000] [2002] Connection refused

For solving the problem I already saw many forum topics and tried such as … - without success:
I had tried to change the database server to localhost or own server IP address.
I created a new user via terminal - by terminal mysql login is possible - on matomo login not.
I checked the port 3306 and 33060.
I gave /var/www/html/matomo www-data permissions.
I had reinstall mysql.

Have someone a hint or idea to solve this error?
Is there another way to see logs related to the issue why matomo can’t login to the mysql?

Here my settings:

docker-compose.yml

version: "3"

services:
  db:
    image: mariadb
    command: --max-allowed-packet=64MB
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=...
      - MYSQL_PASSWORD=...
      - MYSQL_DATABASE=matomo
      - MYSQL_USER=matomo

  app:
    image: matomo
    restart: always
    volumes:
      - matomo:/var/www/html
    environment:
      #- MATOMO_DATABASE_HOST=db
      - MATOMO_DATABASE_ADAPTER=mysql
      - MATOMO_DATABASE_TABLES_PREFIX=matomo_
      - MATOMO_DATABASE_USERNAME=matomo
      - MATOMO_DATABASE_PASSWORD=...
      - MATOMO_DATABASE_DBNAME=matomo
    ports:
      - 8080:80

volumes:
  db:
    driver_opts:
      type: none
      device: /var/lib/docker/volumes/...
      o: bind

  matomo:
    driver_opts:
      type: none
      device: /var/lib/docker/volumes/...
      o: bind

Hi,

I have to say that I know hardly anything about using Matomo with Docker (and Docker in general).

But there is one things I notice: Your docker containers are all running in separate networks (I think), so I think it makes sense that they can’t connect to each other.

In one of the official examples (https://github.com/matomo-org/docker/blob/master/.examples/nginx/docker-compose.yml)

I see a

    links:
      - db

line in the php container, which might help to add.