Unable to install Nextcloud - Database Error [Docker]

[/details]

Nextcloud version (eg, 20.0.5): 28.0.2
Operating system and version (eg, Ubuntu 20.04): Raspberry Pi

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Using the docker compose file
version: "3"
volumes:
  nextcloud-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /portainer/test/nextcloud
  mysql-db:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /portainer/test/mysql
  proxymanager-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /portainer/test/proxymanager/data
  proxymanager-ssl:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /portainer/test/proxymanager/ssl

services:
  nextcloud-app:
    image: nextcloud
    container_name: nextcloud-app
    restart: always
    volumes:
      - nextcloud-data:/var/www/html
    environment:
      - MYSQL_PASSWORD=<redacted>
      - MYSQL_DATABASE=common
      - MYSQL_USER=prateek-nextcloud
      - MYSQL_HOST=localhost
      - PHP_UPLOAD_LIMIT=10G
      - PHP_MEMORY_LIMIT=3G
      - REDIS_HOST=localhost
      - REDIS_PORT=6379
      - REDIS_HOST_PASSWORD=<redacted>
    depends_on:
      - mysql-db
      - redis
    network_mode: "service:vpn"
    entrypoint: sh -c "apt update && apt install -y ffmpeg && apt install -y aria2 && exec /entrypoint.sh apache2-foreground" # Dependencies for NCDownloader

  mysql-db:
    image: mysql
    container_name: mysql-db
    restart: always
    # ports:
    #  - "3306:3306"
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - mysql-db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=<redacted>
      - MYSQL_PASSWORD=<redacted>
      - MYSQL_DATABASE=common
      - MYSQL_USER=prateek-nextcloud
    network_mode: "service:vpn"

  proxymanager:
    image: jc21/nginx-proxy-manager:2.10.2
    container_name: proxymanager
    restart: always
    ports:
      - "80:80"
      - "81:81"
      - "443:443"
    volumes:
      - proxymanager-data:/data
      - proxymanager-ssl:/etc/letsencrypt
    depends_on:
      - nextcloud-app

  redis:
   image: redis
   container_name: redis
   restart: always
   command: redis-server --requirepass <redacted>
   network_mode: "service:vpn"

  vpn:
    image: qmcgaw/gluetun
    container_name: vpn
    cap_add:
      - NET_ADMIN
    environment:
      - VPN_SERVICE_PROVIDER=surfshark
      - OPENVPN_USER=<redacted>
      - OPENVPN_PASSWORD=<redacted>
      - SERVER_COUNTRIES=Netherlands
    ports:
      - "90:80"
      - "6800:6800"
      - "51413:51413" #BT Port
  1. Configure NGinx to route domain requests to http://<Local IP of machine>:90

The output of your Nextcloud log in Admin > Logging:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory 

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'password' => 'Daqts1qq!e',
    'port' => 6379,
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'oc7l09t9g9zp',
  'passwordsalt' => 'RXrjZBYOYHcHc9OZ1AREBiNN1GnF8m',
  'secret' => 'Wu4TL7QM61rdtZwSUj4N6hr3IWOkDDIoH2jxrBcSS8J7He1V',
  'trusted_domains' => 
  array (
    0 => 'prateeknar.cloud',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '28.0.2.5',
  'overwrite.cli.url' => 'http://prateeknar.cloud',
  'dbname' => 'common',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
);

You’re using Docker so your db is not localhost. It’s running in a container (think of it as a VM for networking purposes). Use whatever the db container name is, but not localhost.

You have the same issue with your Redis service reference:

 - REDIS_HOST=localhost