Nextcloud Full Stack
Nextcloud with PostgreSQL, Redis, and Collabora Office.
Overview
Nextcloud is an open-source, self-hosted productivity platform that serves as a complete alternative to commercial cloud services like Google Workspace or Microsoft 365. Originally forked from ownCloud in 2016, Nextcloud has evolved into a comprehensive collaboration suite offering file synchronization, sharing, calendar, contacts, video calls, and document editing capabilities. With over 200 available apps and strong privacy controls, it enables organizations to maintain complete control over their data while providing modern cloud functionality.
This full-stack deployment combines Nextcloud with PostgreSQL for robust data storage, Redis for high-performance caching and session management, and Collabora Office for real-time collaborative document editing. PostgreSQL provides ACID-compliant data integrity and advanced querying capabilities essential for Nextcloud's complex metadata and sharing permissions. Redis dramatically improves performance by caching frequently accessed data and managing user sessions in memory, while Collabora Office transforms Nextcloud into a complete office suite with LibreOffice-powered online editing.
This configuration is ideal for organizations seeking a privacy-focused alternative to commercial cloud platforms, educational institutions requiring collaborative tools without vendor lock-in, and teams needing enterprise-grade file sharing with integrated office capabilities. The combination delivers sub-second file access through Redis caching, reliable data storage via PostgreSQL's proven architecture, and professional document collaboration through Collabora's LibreOffice integration.
Key Features
- Real-time collaborative document editing with LibreOffice Online through Collabora Office
- Sub-millisecond file access and session management via Redis in-memory caching
- ACID-compliant data storage with PostgreSQL's advanced transaction support
- Cross-device file synchronization with conflict resolution and version history
- Comprehensive sharing controls with password protection, expiration dates, and permission levels
- Integrated CalDAV and CardDAV servers for calendar and contact synchronization
- End-to-end encryption for sensitive files with client-side key management
- Extensive app ecosystem with over 200 plugins for mail, chat, project management, and more
Common Use Cases
- 1Small businesses replacing Google Workspace or Office 365 with self-hosted alternative
- 2Educational institutions providing students and faculty with collaborative document editing
- 3Healthcare organizations requiring HIPAA-compliant file sharing and storage
- 4Remote teams needing centralized file access with real-time document collaboration
- 5Government agencies implementing privacy-focused cloud storage with data sovereignty
- 6Creative agencies sharing large media files with clients through branded portals
- 7Home labs and personal clouds for family file sharing and photo backup
Prerequisites
- Minimum 3GB RAM (1GB+ for PostgreSQL, 512MB+ for Redis, 2GB+ for Nextcloud with Collabora)
- 20GB+ available disk space for application data and user files
- Ports 8080 (Nextcloud) and 9980 (Collabora) available on the host system
- Basic understanding of Nextcloud administration and app installation
- Domain name or reverse proxy setup for production SSL/TLS termination
- Firewall configuration allowing HTTP/HTTPS traffic for external access
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 postgres: 3 image: postgres:16-alpine4 container_name: nextcloud-postgres5 restart: unless-stopped6 environment: 7 POSTGRES_USER: ${POSTGRES_USER:-nextcloud}8 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nextcloud}9 POSTGRES_DB: ${POSTGRES_DB:-nextcloud}10 volumes: 11 - postgres_data:/var/lib/postgresql/data12 networks: 13 - nextcloud-network1415 redis: 16 image: redis:alpine17 container_name: nextcloud-redis18 restart: unless-stopped19 volumes: 20 - redis_data:/data21 networks: 22 - nextcloud-network2324 nextcloud: 25 image: nextcloud:latest26 container_name: nextcloud27 restart: unless-stopped28 ports: 29 - "${NEXTCLOUD_PORT:-8080}:80"30 environment: 31 - POSTGRES_HOST=postgres32 - POSTGRES_DB=${POSTGRES_DB:-nextcloud}33 - POSTGRES_USER=${POSTGRES_USER:-nextcloud}34 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nextcloud}35 - REDIS_HOST=redis36 - NEXTCLOUD_ADMIN_USER=${ADMIN_USER:-admin}37 - NEXTCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}38 - NEXTCLOUD_TRUSTED_DOMAINS=${TRUSTED_DOMAINS:-localhost}39 volumes: 40 - nextcloud_data:/var/www/html41 depends_on: 42 - postgres43 - redis44 networks: 45 - nextcloud-network4647 collabora: 48 image: collabora/code:latest49 container_name: collabora50 restart: unless-stopped51 ports: 52 - "${COLLABORA_PORT:-9980}:9980"53 environment: 54 - domain=${NEXTCLOUD_DOMAIN:-localhost}55 - extra_params=--o:ssl.enable=false56 cap_add: 57 - MKNOD58 networks: 59 - nextcloud-network6061volumes: 62 postgres_data: 63 redis_data: 64 nextcloud_data: 6566networks: 67 nextcloud-network: 68 driver: bridge.env Template
.env
1# Nextcloud Full Stack2NEXTCLOUD_PORT=80803COLLABORA_PORT=99804POSTGRES_USER=nextcloud5POSTGRES_PASSWORD=nextcloud6POSTGRES_DB=nextcloud7ADMIN_USER=admin8ADMIN_PASSWORD=admin9TRUSTED_DOMAINS=localhost10NEXTCLOUD_DOMAIN=localhostUsage Notes
- 1Nextcloud at http://localhost:8080
- 2Collabora at http://localhost:9980
- 3Install Collabora app in Nextcloud
- 4Edit Office docs in browser
Individual Services(4 services)
Copy individual services to mix and match with your existing compose files.
postgres
postgres:
image: postgres:16-alpine
container_name: nextcloud-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-nextcloud}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nextcloud}
POSTGRES_DB: ${POSTGRES_DB:-nextcloud}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- nextcloud-network
redis
redis:
image: redis:alpine
container_name: nextcloud-redis
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- nextcloud-network
nextcloud
nextcloud:
image: nextcloud:latest
container_name: nextcloud
restart: unless-stopped
ports:
- ${NEXTCLOUD_PORT:-8080}:80
environment:
- POSTGRES_HOST=postgres
- POSTGRES_DB=${POSTGRES_DB:-nextcloud}
- POSTGRES_USER=${POSTGRES_USER:-nextcloud}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nextcloud}
- REDIS_HOST=redis
- NEXTCLOUD_ADMIN_USER=${ADMIN_USER:-admin}
- NEXTCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
- NEXTCLOUD_TRUSTED_DOMAINS=${TRUSTED_DOMAINS:-localhost}
volumes:
- nextcloud_data:/var/www/html
depends_on:
- postgres
- redis
networks:
- nextcloud-network
collabora
collabora:
image: collabora/code:latest
container_name: collabora
restart: unless-stopped
ports:
- ${COLLABORA_PORT:-9980}:9980
environment:
- domain=${NEXTCLOUD_DOMAIN:-localhost}
- extra_params=--o:ssl.enable=false
cap_add:
- MKNOD
networks:
- nextcloud-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 postgres:5 image: postgres:16-alpine6 container_name: nextcloud-postgres7 restart: unless-stopped8 environment:9 POSTGRES_USER: ${POSTGRES_USER:-nextcloud}10 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nextcloud}11 POSTGRES_DB: ${POSTGRES_DB:-nextcloud}12 volumes:13 - postgres_data:/var/lib/postgresql/data14 networks:15 - nextcloud-network1617 redis:18 image: redis:alpine19 container_name: nextcloud-redis20 restart: unless-stopped21 volumes:22 - redis_data:/data23 networks:24 - nextcloud-network2526 nextcloud:27 image: nextcloud:latest28 container_name: nextcloud29 restart: unless-stopped30 ports:31 - "${NEXTCLOUD_PORT:-8080}:80"32 environment:33 - POSTGRES_HOST=postgres34 - POSTGRES_DB=${POSTGRES_DB:-nextcloud}35 - POSTGRES_USER=${POSTGRES_USER:-nextcloud}36 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nextcloud}37 - REDIS_HOST=redis38 - NEXTCLOUD_ADMIN_USER=${ADMIN_USER:-admin}39 - NEXTCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}40 - NEXTCLOUD_TRUSTED_DOMAINS=${TRUSTED_DOMAINS:-localhost}41 volumes:42 - nextcloud_data:/var/www/html43 depends_on:44 - postgres45 - redis46 networks:47 - nextcloud-network4849 collabora:50 image: collabora/code:latest51 container_name: collabora52 restart: unless-stopped53 ports:54 - "${COLLABORA_PORT:-9980}:9980"55 environment:56 - domain=${NEXTCLOUD_DOMAIN:-localhost}57 - extra_params=--o:ssl.enable=false58 cap_add:59 - MKNOD60 networks:61 - nextcloud-network6263volumes:64 postgres_data:65 redis_data:66 nextcloud_data:6768networks:69 nextcloud-network:70 driver: bridge71EOF7273# 2. Create the .env file74cat > .env << 'EOF'75# Nextcloud Full Stack76NEXTCLOUD_PORT=808077COLLABORA_PORT=998078POSTGRES_USER=nextcloud79POSTGRES_PASSWORD=nextcloud80POSTGRES_DB=nextcloud81ADMIN_USER=admin82ADMIN_PASSWORD=admin83TRUSTED_DOMAINS=localhost84NEXTCLOUD_DOMAIN=localhost85EOF8687# 3. Start the services88docker compose up -d8990# 4. View logs91docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/nextcloud-full/run | bashTroubleshooting
- Collabora connection failed: Ensure NEXTCLOUD_DOMAIN environment variable matches your actual domain and install the Collabora Online app in Nextcloud admin panel
- Database connection errors: Verify POSTGRES_PASSWORD matches between postgres and nextcloud services, and ensure PostgreSQL container is fully started before Nextcloud
- Redis cache not working: Check Redis container logs for memory issues and ensure REDIS_HOST environment variable points to the correct service name
- File uploads failing: Increase PHP memory limits and upload size in Nextcloud config.php or add custom php.ini volume mount
- Trusted domain warnings: Add your domain/IP to NEXTCLOUD_TRUSTED_DOMAINS environment variable or configure through admin interface
- Collabora documents won't open: Verify domain configuration in Collabora settings matches NEXTCLOUD_DOMAIN and check that both services can communicate on the Docker network
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
Components
nextcloudpostgresqlrediscollabora
Tags
#nextcloud#cloud#file-sync#collaboration#office
Category
Storage & BackupAd Space
Shortcuts: C CopyF FavoriteD Download