After my previous post, I was somehow able to get nextcloud:fpm up and running after almost a month of troubleshooting (yayy!!), but now I am facing a different challenge, now it is with cron.php. I first did the normal method of changing the background job engine from ajax to cron, hoping that it would be that easy; but i couldnt be more wrong. the cron job failed after ten minutes, and I got confused. I followed similar instructions to the official nextcloud:fpm tutorial on github and sure enough there was a separate container just for cron. I used the same exact configuration in my docker-compose.yaml.
This is my current working compose file, It is a little overengineered, but it is more reliable:
services:
nginx:
image: nginx:alpine
container_name: nextcloud-nginx
restart: unless-stopped
volumes:
- /mnt/SysHDD/Docker-Compose/nextcloud/nginx/:/etc/nginx/:rw
- /home/server-inspiron/.acme.sh/:/mnt/certs/:ro
- web:/var/www/html:z,ro
ports:
- 443:443
- 80:80
- 8096:81
- 8920:82
networks:
nextcloud:
ipv4_address: 172.21.128.4
mariadb:
image: mariadb
container_name: nextcloud-mariadb
restart: unless-stopped
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed
volumes:
- /mnt/SysHDD/Databases/nextcloud-mariadb/:/var/lib/mysql/:rw
env_file:
- db.env
networks:
nextcloud:
ipv4_address: 172.21.128.1
redis:
image: redis:alpine
container_name: nextcloud-redis
restart: always
volumes:
- /mnt/SysHDD/Databases/nextcloud-redis/:/etc/redis
command: redis-server --requirepass password
networks:
nextcloud:
ipv4_address: 172.21.128.2
app:
image: nextcloud:fpm-alpine
restart: unless-stopped
container_name: nextcloud-web
user: 33:1001
links:
- mariadb
- redis
volumes:
- web:/var/www/html
- /mnt/SysHDD/:/mnt/SysHDD/:rw
- /mnt/SSD/:/mnt/SSD/:rw
- /mnt/HDD0/:/mnt/HDD0/:rw
- /mnt/HDD1/:/mnt/HDD1/:rw
environment:
- MYSQL_HOST=172.21.128.1:3306
- REDIS_HOST_PASSWORD=password
env_file:
- db.env
depends_on:
- mariadb
- redis
networks:
nextcloud:
ipv4_address: 172.21.128.3
cron:
image: nextcloud:fpm-alpine
user: 33:1001
restart: unless-stopped
container_name: nextcloud-cron
volumes:
- web:/var/www/html:z
- /mnt/SysHDD/:/mnt/SysHDD/:rw
- /mnt/SSD/:/mnt/SSD/:rw
- /mnt/HDD0/:/mnt/HDD0/:rw
- /mnt/HDD1/:/mnt/HDD1/:rw
entrypoint: /cron.sh
environment:
- MYSQL_HOST=172.21.128.1:3306
env_file:
- db.env
depends_on:
- mariadb
- redis
volumes:
nextcloud-mariadb:
web:
networks:
nextcloud:
driver: bridge
ipam:
config:
- subnet: 172.21.0.0/16
gateway: 172.21.0.1
after i saw cron failed, I ran docker exec -it -u 0 nextcloud-cron /bin/sh
so that I can see what happens when I run cron.php manually.
I use the command php --define apc-enable_cli=1 -f cron.php
, and I wait.
normally a successful cron shouldve taken like 3 seconds, but here I was waiting for around ten minutes, after which the following error popped up, along with a stack trace:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Operation timed out in /var/www/html/lib/private/DB/Connection.php:233
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/lib/private/DB/Connection.php(899): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/lib/private/DB/ConnectionAdapter.php(235): OC\DB\Connection->getDatabaseProvider()
#5 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(96): OC\DB\ConnectionAdapter->getDatabaseProvider()
#6 /var/www/html/lib/private/AppConfig.php(1211): OC\DB\QueryBuilder\QueryBuilder->expr()
#7 /var/www/html/lib/private/AppConfig.php(237): OC\AppConfig->loadConfig(false)
#8 /var/www/html/lib/private/AppConfig.php(1351): OC\AppConfig->searchValues('enabled', false, 2)
#9 /var/www/html/lib/private/App/AppManager.php(126): OC\AppConfig->getValues(false, 'enabled')
#10 /var/www/html/lib/private/App/AppManager.php(147): OC\App\AppManager->getInstalledAppsValues()
#11 /var/www/html/lib/private/legacy/OC_App.php(191): OC\App\AppManager->getInstalledApps()
#12 /var/www/html/lib/private/AppFramework/Bootstrap/Coordinator.php(48): OC_App::getEnabledApps()
#13 /var/www/html/lib/base.php(657): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#14 /var/www/html/lib/base.php(1132): OC::init()
#15 /var/www/html/cron.php(24): require_once('/var/www/html/l...')
#16 {main}
At first, I thought the container isn’t able to log into the database, so i changed the docker compose file to include the mysql credentials in the cron service as well, and then retried the same command. still the same issue. I am unable to decipher the honestly very cryptic error messages, so I am asking the community again to lend me a hand here. Thank you.