docker.recipes

Nextcloud Full Stack

intermediate

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-alpine
4 container_name: nextcloud-postgres
5 restart: unless-stopped
6 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/data
12 networks:
13 - nextcloud-network
14
15 redis:
16 image: redis:alpine
17 container_name: nextcloud-redis
18 restart: unless-stopped
19 volumes:
20 - redis_data:/data
21 networks:
22 - nextcloud-network
23
24 nextcloud:
25 image: nextcloud:latest
26 container_name: nextcloud
27 restart: unless-stopped
28 ports:
29 - "${NEXTCLOUD_PORT:-8080}:80"
30 environment:
31 - POSTGRES_HOST=postgres
32 - POSTGRES_DB=${POSTGRES_DB:-nextcloud}
33 - POSTGRES_USER=${POSTGRES_USER:-nextcloud}
34 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nextcloud}
35 - REDIS_HOST=redis
36 - 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/html
41 depends_on:
42 - postgres
43 - redis
44 networks:
45 - nextcloud-network
46
47 collabora:
48 image: collabora/code:latest
49 container_name: collabora
50 restart: unless-stopped
51 ports:
52 - "${COLLABORA_PORT:-9980}:9980"
53 environment:
54 - domain=${NEXTCLOUD_DOMAIN:-localhost}
55 - extra_params=--o:ssl.enable=false
56 cap_add:
57 - MKNOD
58 networks:
59 - nextcloud-network
60
61volumes:
62 postgres_data:
63 redis_data:
64 nextcloud_data:
65
66networks:
67 nextcloud-network:
68 driver: bridge

.env Template

.env
1# Nextcloud Full Stack
2NEXTCLOUD_PORT=8080
3COLLABORA_PORT=9980
4POSTGRES_USER=nextcloud
5POSTGRES_PASSWORD=nextcloud
6POSTGRES_DB=nextcloud
7ADMIN_USER=admin
8ADMIN_PASSWORD=admin
9TRUSTED_DOMAINS=localhost
10NEXTCLOUD_DOMAIN=localhost

Usage Notes

  1. 1Nextcloud at http://localhost:8080
  2. 2Collabora at http://localhost:9980
  3. 3Install Collabora app in Nextcloud
  4. 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 file
2cat > docker-compose.yml << 'EOF'
3services:
4 postgres:
5 image: postgres:16-alpine
6 container_name: nextcloud-postgres
7 restart: unless-stopped
8 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/data
14 networks:
15 - nextcloud-network
16
17 redis:
18 image: redis:alpine
19 container_name: nextcloud-redis
20 restart: unless-stopped
21 volumes:
22 - redis_data:/data
23 networks:
24 - nextcloud-network
25
26 nextcloud:
27 image: nextcloud:latest
28 container_name: nextcloud
29 restart: unless-stopped
30 ports:
31 - "${NEXTCLOUD_PORT:-8080}:80"
32 environment:
33 - POSTGRES_HOST=postgres
34 - POSTGRES_DB=${POSTGRES_DB:-nextcloud}
35 - POSTGRES_USER=${POSTGRES_USER:-nextcloud}
36 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nextcloud}
37 - REDIS_HOST=redis
38 - 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/html
43 depends_on:
44 - postgres
45 - redis
46 networks:
47 - nextcloud-network
48
49 collabora:
50 image: collabora/code:latest
51 container_name: collabora
52 restart: unless-stopped
53 ports:
54 - "${COLLABORA_PORT:-9980}:9980"
55 environment:
56 - domain=${NEXTCLOUD_DOMAIN:-localhost}
57 - extra_params=--o:ssl.enable=false
58 cap_add:
59 - MKNOD
60 networks:
61 - nextcloud-network
62
63volumes:
64 postgres_data:
65 redis_data:
66 nextcloud_data:
67
68networks:
69 nextcloud-network:
70 driver: bridge
71EOF
72
73# 2. Create the .env file
74cat > .env << 'EOF'
75# Nextcloud Full Stack
76NEXTCLOUD_PORT=8080
77COLLABORA_PORT=9980
78POSTGRES_USER=nextcloud
79POSTGRES_PASSWORD=nextcloud
80POSTGRES_DB=nextcloud
81ADMIN_USER=admin
82ADMIN_PASSWORD=admin
83TRUSTED_DOMAINS=localhost
84NEXTCLOUD_DOMAIN=localhost
85EOF
86
87# 3. Start the services
88docker compose up -d
89
90# 4. View logs
91docker 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-full/run | bash

Troubleshooting

  • 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

Ad Space