All articles
2 min read

Installing Nextcloud on Raspberry Pi: A Comprehensive Guide

Set up your own private cloud storage with Nextcloud on a Raspberry Pi using Docker. Covers quick start, persistent volumes, PostgreSQL backend, and Docker Compose setup.

Nextcloud is an open-source self-hosted cloud platform — file storage, calendar, contacts, and collaboration tools that run on your own hardware. Running it on a Raspberry Pi gives you a private alternative to Google Drive or Dropbox that stays on your network.

This guide uses Docker, which is the easiest way to get Nextcloud running and keeps the installation isolated from your Pi's base system.

Prerequisites

  • Docker installed on your Pi (install guide)
  • Ports 80 (or a custom port) accessible on your network

Quick Start

The fastest way to get Nextcloud running:

docker run -d -p 7000:80 --name nextcloud nextcloud

Navigate to http://<your-pi-ip>:7000 to complete setup. The first screen asks you to create an admin account and choose a database (SQLite is fine for single-user or testing).

Limitation: Data is stored inside the container and will be lost if the container is removed.

With Persistent Volumes

For a proper installation where your data survives container restarts and upgrades:

docker run -d -p 7000:80 --name nextcloud --restart=always \
    -v /dkr/nextcloud/html:/var/www/html \
    -v /dkr/nextcloud/apps:/var/www/html/custom_apps \
    -v /dkr/nextcloud/config:/var/www/html/config \
    -v /dkr/nextcloud/data:/var/www/html/data \
    nextcloud

This maps Nextcloud's data directories to /dkr/nextcloud/ on the Pi's filesystem. You can back up that directory to preserve your files and configuration.

Recommended Setup: Docker Compose with PostgreSQL

For multi-user or production-like use, connect Nextcloud to a PostgreSQL database instead of SQLite. Docker Compose manages both containers as a unit:

docker-compose.yml:

version: "3.8"

services:
  db:
    image: postgres:15-alpine
    restart: always
    volumes:
      - /dkr/postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: change_this_password

  nextcloud:
    image: nextcloud:latest
    restart: always
    ports:
      - "7000:80"
    depends_on:
      - db
    volumes:
      - /dkr/nextcloud/html:/var/www/html
      - /dkr/nextcloud/data:/var/www/html/data
      - /dkr/nextcloud/config:/var/www/html/config
    environment:
      POSTGRES_HOST: db
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: change_this_password
      NEXTCLOUD_ADMIN_USER: admin
      NEXTCLOUD_ADMIN_PASSWORD: change_this_admin_password

Start both services:

docker compose up -d

The NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD environment variables pre-configure the admin account — no manual setup screen needed.

First-Time Access

  1. Open http://<your-pi-ip>:7000 in your browser
  2. If you used the environment variables approach, log in with the admin credentials you set
  3. Otherwise, create an admin account when prompted

Accessing Nextcloud from Outside Your Network

To reach your Nextcloud from the internet, you'll need either:

For remote access, always add HTTPS via a reverse proxy (Nginx + Let's Encrypt). Running Nextcloud over plain HTTP is not recommended for public access.

Updating Nextcloud

With Docker Compose:

docker compose pull
docker compose up -d

Docker pulls the latest Nextcloud image and restarts the container. Your data volumes remain untouched.

Conclusion

Nextcloud on a Raspberry Pi gives you a capable private cloud without a monthly subscription. The Docker Compose + PostgreSQL setup is the most maintainable path — it separates data from the application, makes upgrades trivial, and scales to multiple users. Start with the quick start to get familiar with Nextcloud, then migrate to the Compose setup before putting any real data in.