Nextcloud Docker - Unalbe to connect to MariaDB SQLSTATE[HY000] [2002]

Hi
I have the following docker-compose file from nextcloud examples:

version: '3'

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=****
    env_file:
      - db.env

  app:
    image: nextcloud:apache
    restart: always
    ports:
      - 8080:80
    volumes:
      - nextcloud:/var/www/html
    networks:
      - frontproxy_default
    environment:
      - MYSQL_HOST=db
      - VIRTUAL_HOST=example.org
      - LETSENCRYPT_HOST=example.org
      - LETSENCRYPT_EMAIL=example@example.org
    env_file:
      - db.env
    depends_on:
      - db

volumes:
  db:
  nextcloud:

networks:
  frontproxy_default:
    external: true

db.env:
MYSQL_PASSWORD=****
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud

I can see the startpage, with only the Username and PW.
After I enter those the error message appeared:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away

Any suggestion??

I have read that mariadb 10.3.22 is required. So I changed the image to that version. Now I get this error:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Any help?

Is this a new or existing setup?

You can run docker-compose ps and confirm the database is running.

i guess your nextcloud container is only connected to the frontend network. and your mariadb isn’t.

Yeah this was the solution I added frontproxy_default also to the db.
What I also did is change the password to a more simple one, before I had a lot of special characters in it…