Nextcloud in Docker- Linked database issue?

Itā€™s time to ask for help. Iā€™ve been trying to setup my first nextcloud install for a long time, without success. My host is a Synology NAS and Iā€™m trying to run everything within docker. Iā€™ve chosen postresql for my database, although I also tried Mariadb with no success.

My install starts and I can get to the ā€˜create admin userā€™ page, but something goes wrong when writing this user to the database. An ambiguous ā€œInternal Server Errorā€ message is shown.

Looking at the docker container logs is unenlightening. The only thing to note is that it appears that my database container is not actually receiving any connections. Looking at nextcloud.log under the data folder shows some interesting errors:

Error trying to connect as \"postgres\", assuming database is setup and tables need to be created
Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] timeout expired"

Removing postgres and using the default sqlite database allows everything to start.

My docker-compose is pretty standard. Iā€™m using the fpm version of nextcloud, with NGINX as my web-host. Iā€™ll add redis, cron, encryption and a proxy once the basic stuff is working.

DATA_DIR is passed from a .env

version: '3' 

services:
  web:
    build: ./build_web # Nothing fancy going on here. Just copying the NGINX config.
    restart: unless-stopped
    ports:
      - 9090:80 # Using port 9090 for testing.
    volumes:
      - ${DATA_DIR}/html:/var/www/html:ro
    environment:
      - TZ=Australia/Sydney
    depends_on:
      - app
    networks:
      - external_net
      - internal_net

  db:
    image: postgres
    restart: unless-stopped
    volumes:
      - ${DATA_DIR}/db:/var/lib/postgresql/data
    environment:
      - TZ=Australia/Sydney
      - POSTGRES_DB=nextcloud
      - POSTGRES_PASSWORD=somepassword
      - POSTGRES_USER=nextcloud
    networks:
      - internal_net

  app:
    image: nextcloud:fpm
    restart: unless-stopped
    depends_on:
      - db
    volumes:
      - ${DATA_DIR}/html:/var/www/html
      - ${DATA_DIR}/data:/var/www/html/data
    environment:
      - TZ=Australia/Sydney
      - POSTGRES_HOST=db
      - POSTGRES_DB=nextcloud
      - POSTGRES_PASSWORD=somepassword
      - POSTGRES_USER=nextcloud
      - NEXTCLOUD_UPDATE=1
    networks:
      - internal_net

networks:
  internal_net:
  external_net:

Any ideas for what I could try?