docker.recipes

Nextcloud

intermediate

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

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.

Key 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

Common Use Cases

  • 1Replace Google Workspace or Microsoft 365 for small to medium businesses requiring data privacy
  • 2Educational institutions needing FERPA-compliant file sharing and collaboration platform
  • 3Remote teams requiring secure file sync with integrated video conferencing capabilities
  • 4Healthcare organizations managing patient data with HIPAA compliance requirements
  • 5Software development teams sharing code repositories and project documentation
  • 6Home lab enthusiasts creating personal cloud storage with family sharing features
  • 7Non-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

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 nextcloud:
3 image: nextcloud:apache
4 container_name: nextcloud
5 restart: unless-stopped
6 environment:
7 MYSQL_HOST: mariadb
8 MYSQL_DATABASE: ${MYSQL_DATABASE}
9 MYSQL_USER: ${MYSQL_USER}
10 MYSQL_PASSWORD: ${MYSQL_PASSWORD}
11 REDIS_HOST: redis
12 volumes:
13 - nextcloud_data:/var/www/html
14 ports:
15 - "8080:80"
16 depends_on:
17 - mariadb
18 - redis
19 networks:
20 - nextcloud
21
22 mariadb:
23 image: mariadb:11
24 container_name: nextcloud-mariadb
25 environment:
26 MARIADB_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
27 MARIADB_DATABASE: ${MYSQL_DATABASE}
28 MARIADB_USER: ${MYSQL_USER}
29 MARIADB_PASSWORD: ${MYSQL_PASSWORD}
30 volumes:
31 - mariadb_data:/var/lib/mysql
32 networks:
33 - nextcloud
34
35 redis:
36 image: redis:alpine
37 container_name: nextcloud-redis
38 networks:
39 - nextcloud
40
41volumes:
42 nextcloud_data:
43 mariadb_data:
44
45networks:
46 nextcloud:
47 driver: bridge

.env Template

.env
1MYSQL_ROOT_PASSWORD=rootpassword
2MYSQL_DATABASE=nextcloud
3MYSQL_USER=nextcloud
4MYSQL_PASSWORD=changeme

Usage Notes

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

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

nextcloud
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
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
redis:
  image: redis:alpine
  container_name: nextcloud-redis
  networks:
    - nextcloud

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 nextcloud:
5 image: nextcloud:apache
6 container_name: nextcloud
7 restart: unless-stopped
8 environment:
9 MYSQL_HOST: mariadb
10 MYSQL_DATABASE: ${MYSQL_DATABASE}
11 MYSQL_USER: ${MYSQL_USER}
12 MYSQL_PASSWORD: ${MYSQL_PASSWORD}
13 REDIS_HOST: redis
14 volumes:
15 - nextcloud_data:/var/www/html
16 ports:
17 - "8080:80"
18 depends_on:
19 - mariadb
20 - redis
21 networks:
22 - nextcloud
23
24 mariadb:
25 image: mariadb:11
26 container_name: nextcloud-mariadb
27 environment:
28 MARIADB_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
29 MARIADB_DATABASE: ${MYSQL_DATABASE}
30 MARIADB_USER: ${MYSQL_USER}
31 MARIADB_PASSWORD: ${MYSQL_PASSWORD}
32 volumes:
33 - mariadb_data:/var/lib/mysql
34 networks:
35 - nextcloud
36
37 redis:
38 image: redis:alpine
39 container_name: nextcloud-redis
40 networks:
41 - nextcloud
42
43volumes:
44 nextcloud_data:
45 mariadb_data:
46
47networks:
48 nextcloud:
49 driver: bridge
50EOF
51
52# 2. Create the .env file
53cat > .env << 'EOF'
54MYSQL_ROOT_PASSWORD=rootpassword
55MYSQL_DATABASE=nextcloud
56MYSQL_USER=nextcloud
57MYSQL_PASSWORD=changeme
58EOF
59
60# 3. Start the services
61docker compose up -d
62
63# 4. View logs
64docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/nextcloud/run | bash

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

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space