Back to Blog

Nextcloud: Your Self-Hosted Google Drive in 30 Minutes

Deploy Nextcloud with Docker and replace Google Drive, Calendar, and Contacts with your own private cloud. Complete setup guide for homelab enthusiasts.

Posted by

Nextcloud dashboard interface

Take Back Your Cloud

Google Drive is convenient, but it comes at the cost of your privacy. Google scans your files, builds advertising profiles, and can lock you out at any time. Nextcloud gives you all the functionality of Google's suite while keeping your data under your control.

In this guide, we'll deploy a production-ready Nextcloud instance with Docker in about 30 minutes.

What Nextcloud Replaces

  • Google Drive: File storage and sync across devices
  • Google Docs: Collaborative document editing (with OnlyOffice or Collabora)
  • Google Calendar: Full CalDAV calendar support
  • Google Contacts: CardDAV contact sync
  • Google Photos: Photo backup and organization
  • Google Keep: Notes and tasks

That's potentially $100+ per year in subscriptions replaced by your own server.

Docker Compose Setup

Here's a production-ready docker-compose.yml for Nextcloud with PostgreSQL and Redis:

version: "3.8"

services:
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    ports:
      - "8080:80"
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - REDIS_HOST=redis
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - NEXTCLOUD_TRUSTED_DOMAINS=localhost your.domain.com
    volumes:
      - nextcloud_data:/var/www/html
      - ./data:/var/www/html/data
    depends_on:
      - db
      - redis
    restart: unless-stopped

  db:
    image: postgres:15-alpine
    container_name: nextcloud-db
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      - db_data:/var/lib/postgresql/data
    restart: unless-stopped

  redis:
    image: redis:alpine
    container_name: nextcloud-redis
    restart: unless-stopped

volumes:
  nextcloud_data:
  db_data:

Environment File

Create a .env file in the same directory:

DB_PASSWORD=your_secure_database_password
ADMIN_PASSWORD=your_secure_admin_password

Use strong, random passwords. You can generate them with:

openssl rand -base64 32

Deployment Steps

Follow these steps to get Nextcloud running:

# 1. Create project directory
mkdir nextcloud && cd nextcloud

# 2. Create docker-compose.yml and .env files
# (paste the configurations above)

# 3. Create data directory with proper permissions
mkdir data

# 4. Start the stack
docker compose up -d

# 5. Watch the logs for startup progress
docker compose logs -f nextcloud

After a few minutes, access Nextcloud at http://your-server-ip:8080.

Essential Post-Installation Steps

1. Configure Cron Jobs

Nextcloud needs background jobs for optimal performance:

# Add to your host's crontab
*/5 * * * * docker exec -u www-data nextcloud php cron.php

2. Enable Memory Caching

Redis is already configured in our setup. Verify it's working in Settings → Administration → Overview.

3. Set Up Trusted Domains

If you access Nextcloud via a domain name, add it to the trusted domains in config/config.php:

'trusted_domains' =>
array (
  0 => 'localhost',
  1 => '192.168.1.100',
  2 => 'cloud.yourdomain.com',
),

Recommended Apps

Install these apps from the Nextcloud App Store:

  • Calendar: Full-featured calendar with CalDAV sync
  • Contacts: CardDAV contact management
  • Notes: Markdown notes synced across devices
  • Tasks: Todo lists and task management
  • Photos: AI-powered photo organization
  • Talk: Video calling and chat

Mobile and Desktop Sync

Nextcloud offers excellent client apps:

  • Desktop: Windows, macOS, and Linux sync clients
  • Mobile: iOS and Android apps with auto-upload for photos
  • Calendar sync: Use DAVx5 on Android or built-in CalDAV on iOS

Configure your clients to connect to your Nextcloud URL, and your files will sync automatically.

Security Best Practices

  • Enable HTTPS with a reverse proxy (Traefik or Nginx Proxy Manager)
  • Enable Two-Factor Authentication for all users
  • Set up Fail2ban to prevent brute-force attacks
  • Keep Nextcloud updated regularly
  • Configure automatic backups of both data and database

Your Private Cloud Awaits

Congratulations! You now have your own private cloud that rivals Google's offerings. Your files, calendars, and contacts are stored on hardware you control, with no subscription fees and complete privacy.

As you become more comfortable, explore Nextcloud's extensive app ecosystem to add even more functionality to your self-hosted cloud.

Continue Reading