# Nextcloud

> Self-hosted file sync and share platform with collaborative office suite, calendar, contacts, and extensive app ecosystem.

- Category: Productivity & Collaboration
- Difficulty: intermediate
- Components: nextcloud, mariadb, redis
- Tags: nextcloud, files, sync, collaboration, office, privacy
- Source: https://docker.recipes/productivity/nextcloud

## Overview

Nextcloud is a self-hosted productivity platform that emerged as a fork of ownCloud in 2016, offering comprehensive file synchronization, sharing, and collaboration capabilities. As a privacy-focused alternative to Google Drive and Microsoft 365, Nextcloud provides file storage, collaborative office suite, calendar, contacts, video calls, and an extensive app ecosystem with over 200 applications. This configuration combines Nextcloud with MariaDB for robust database operations and Redis for high-performance caching and session management. MariaDB serves as the primary database backend, providing enhanced features over standard MySQL including improved performance and clustering capabilities, while Redis acts as an in-memory cache to accelerate file operations, user sessions, and transactional locking. This three-component stack delivers enterprise-grade performance for teams requiring self-hosted collaboration tools with complete data sovereignty. Organizations choosing this setup gain a fully-featured productivity platform that rivals commercial cloud services while maintaining complete control over their data, making it ideal for privacy-conscious businesses, educational institutions, and technical teams who need reliable file sync with collaborative features.

## Features

- Real-time file synchronization across desktop and mobile clients with conflict resolution
- Collaborative document editing with OnlyOffice or Collabora Online integration
- CalDAV and CardDAV support for calendar and contact synchronization
- Video conferencing and chat through Nextcloud Talk with screen sharing
- MariaDB's Aria storage engine providing crash-safe tables and improved performance
- Redis-powered session management reducing database load and improving response times
- End-to-end encryption for files with client-side key management
- Extensive app marketplace with workflow automation, project management, and security tools

## Use cases

- Replace Google Workspace or Microsoft 365 for small to medium businesses requiring data privacy
- Educational institutions needing FERPA-compliant file sharing and collaboration platform
- Remote teams requiring secure file sync with integrated video conferencing capabilities
- Healthcare organizations managing patient data with HIPAA compliance requirements
- Software development teams sharing code repositories and project documentation
- Home lab enthusiasts creating personal cloud storage with family sharing features
- Non-profit organizations needing cost-effective collaboration tools with donor data protection

## Prerequisites

- Minimum 3GB RAM (2GB for Nextcloud, 512MB for MariaDB, 256MB for Redis)
- At least 20GB available disk space for initial installation and user data
- Port 8080 available on host system for web interface access
- Basic understanding of environment variables and Docker volume management
- SSL certificate and reverse proxy knowledge for production HTTPS deployment
- Familiarity with Nextcloud admin interface for user management and app installation

## docker-compose.yml

```yaml
services:
  nextcloud:
    image: nextcloud:apache
    container_name: nextcloud
    restart: unless-stopped
    environment:
      MYSQL_HOST: mariadb
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      REDIS_HOST: redis
    volumes:
      - nextcloud_data:/var/www/html
    ports:
      - "8080:80"
    depends_on:
      - mariadb
      - redis
    networks:
      - nextcloud

  mariadb:
    image: mariadb:11
    container_name: nextcloud-mariadb
    environment:
      MARIADB_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MARIADB_DATABASE: ${MYSQL_DATABASE}
      MARIADB_USER: ${MYSQL_USER}
      MARIADB_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql
    networks:
      - nextcloud

  redis:
    image: redis:alpine
    container_name: nextcloud-redis
    networks:
      - nextcloud

volumes:
  nextcloud_data:
  mariadb_data:

networks:
  nextcloud:
    driver: bridge
```

## .env

```bash
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=changeme
```

## Usage notes

- Docs: https://docs.nextcloud.com/server/latest/admin_manual/
- Access at http://localhost:8080 - complete setup wizard on first visit
- Install apps: Files, Calendar, Contacts, Talk (video calls), Office (Collabora/OnlyOffice)
- Enable cron: docker exec -u www-data nextcloud php cron.php (add to host crontab)
- Sync clients available for desktop (Win/Mac/Linux) and mobile (iOS/Android)
- Background jobs: set to Cron in Admin > Basic settings for better performance

## Troubleshooting

- Database connection errors during setup: Verify MYSQL_* environment variables match between nextcloud and mariadb services
- Slow file uploads or timeouts: Increase PHP memory limits and execution time in Nextcloud container using custom php.ini
- Redis connection failures: Check that redis container is running and nextcloud can resolve 'redis' hostname on docker network
- Trusted domain warnings: Add your domain/IP to trusted_domains array in Nextcloud config/config.php file
- MariaDB crashes or corruption: Ensure mariadb_data volume has proper permissions and sufficient disk space
- Background job warnings in admin panel: Set up cron job on host to run 'docker exec -u www-data nextcloud php cron.php' every 5 minutes

