Konstantinos Antoniou.

← Projects

Deploying Nextcloud with MariaDB and Collabora using Docker Compose

Overview

This project demonstrates a self-hosted cloud storage solution using Nextcloud, orchestrated with Docker Compose. The setup integrates:

  • Nextcloud as the main application server
  • MariaDB as the database backend
  • Collabora CODE for online office document editing
  • External persistent storage mounts for scalability and data integrity

This stack is designed for portability, resilience, and data privacy, fully running on a Linux host (in this case, managed via Proxmox with Docker containers).


Project Goals

The purpose of this deployment is to:

  • Build a secure private cloud alternative to Google Drive or Dropbox.
  • Share it with friends and family.
  • Centralize files, calendars, contacts, and photos across all personal and home lab devices.
  • Enable collaborative document editing via Collabora Online.
  • Maintain data ownership, with full control over storage and backups.

Infrastructure Overview

The containers run inside a Docker environment connected to an external network called Apps-Network, which allows seamless communication with other services (e.g., Heimdall dashboard, Nginx proxy, or monitoring tools).

Persistent data is mounted from:

  • /opt/appdata/nextcloud → configuration and app data
  • /media/storage and /media/NFS-WD → external storage directories (NFS)

Network communication between Nextcloud and MariaDB is handled internally within Docker, while HTTPS and Collabora traffic are exposed to the host for user access.

Screenshot 1: Infrastructure Overview


Docker Compose File

Here’s the full Compose configuration used for this project:

services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:latest
    container_name: Nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Athens
    volumes:
      - /opt/appdata/nextcloud/config:/config
      - /opt/appdata/nextcloud/data:/data
      - /media/storage:/Storage
      - /media/NFS-WD:/media/NFS-WD
    ports:
      - 443:443
    depends_on:
      - mariadb
    restart: unless-stopped

  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: Nextcloud-db
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Athens
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - /opt/appdata/nextcloud_db/config:/config
      - /opt/appdata/nextcloud_db/data:/data
    ports:
      - 3306:3306
    restart: unless-stopped

  code:
    image: collabora/code:latest
    container_name: Nextcloud-office
    restart: unless-stopped
    environment:
      - password=${COLLABORA_PASSWORD}
      - username=${COLLABORA_USERNAME}
      - domain=${COLLABORA_DOMAIN}
      - extra_params=--o:ssl.enable=true
    ports:
      - 9980:9980

networks:
  default:
    external: true
    name: Apps-Network

Step-by-Step Deployment Guide

1. Create an External Docker Network

This network allows services across multiple stacks (like Heimdall, Nextcloud, or Nginx Proxy Manager) to communicate:

docker network create Apps-Network

2. Prepare Persistent Storage Paths

Before launching, ensure all directories exist:

sudo mkdir -p /opt/appdata/nextcloud/config sudo mkdir -p /opt/appdata/nextcloud/data sudo mkdir -p /opt/appdata/nextcloud_db/config sudo mkdir -p /opt/appdata/nextcloud_db/data

Then mount or link your storage drives:

sudo mkdir -p /media/storage sudo mkdir -p /media/NFS-WD

3. Define Environment Variables

Create a .env file in the same directory as your Compose file:

MYSQL_ROOT_PASSWORD=StrongRootPass123 MYSQL_DATABASE=nextcloud MYSQL_USER=nextclouduser MYSQL_PASSWORD=UserPass456

COLLABORA_PASSWORD=collaboraPass789 COLLABORA_USERNAME=collabora COLLABORA_DOMAIN=cloud\.example\.com

The domain variable for Collabora must be escaped with backslashes if it includes dots (required by regex matching).

4. Deploy the Stack

Start the containers:

docker compose up -d

Verify:

docker ps

You should see three running containers:

Nextcloud Nextcloud-db Nextcloud-office


5. Initial Nextcloud Setup

Access the Nextcloud instance in your browser:

https://internal-ip/

  • Set an admin username and password
  • Under “Database configuration,” choose MySQL/MariaDB
    • Database user: nextclouduser
    • Database name: nextcloud
    • Password: Super_Str0ng-Password!!!
    • Host: mariadb

After installation, you’ll be redirected to the Nextcloud dashboard.


6. Integrating Collabora CODE

In Nextcloud:

  • Go to Settings → Collabora Online
  • Set the Collabora server to:
  • https://your-server-ip:9980
  • Authenticate with your configured Collabora credentials.

You can now open and edit .docx, .odt, .pptx, and .xlsx files directly from the Nextcloud web interface.


Security & Optimization 

  • Used a Cloudflare Tunnel for external HTTPS access, https://black-crab.cc is my domain
  • Regularly back up /opt/appdata/ and my storage directories
  • I have enabled 2FA on both email and OTP.

Last Thoughts

This deployment shows my DevOps skillset in container orchestration, networking, and infrastructure-as-code principles.