The Easiest Way to Install Nextcloud on Portainer

If you are tired of trusting your personal files to companies like Google and Microsoft, companies that scan your data and can lock your account at any moment, it is time to take back control.

Nextcloud is the ultimate open-source alternative to Google Drive. It offers file sync, calendars, contacts, and notes, all hosted on your own hardware.

In this guide, I’ll show you the easiest way to install Nextcloud using Portainer.

1. Prerequisites

Before we start, you need a server running Portainer and a Reverse Proxy. If you don’t have these yet, follow my guides below:

2. The Docker Compose File

We will use the LinuxServer.io images for both Nextcloud and the MariaDB database. Using a dedicated database (MariaDB) instead of the built-in SQLite is critical for performance.

  1. Log in to Portainer.
  2. Go to Stacks -> Add stack.
  3. Name it nextcloud.
  4. Paste the following configuration:
services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:latest
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Vienna
    volumes:
      - /mnt/nc-data/config:/config
      - /mnt/nc-data/data:/data
    ports:
      - 444:443
    restart: unless-stopped

  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: nextcloud-mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Vienna
      - MYSQL_ROOT_PASSWORD=amazingpassword
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=amazingpassword
    volumes:
      - /mnt/nc-data/sql:/config
    ports:
      - 3336:3306
    restart: unless-stopped

Note: Make sure to change the passwords (amazingpassword) to something secure!

Click Deploy the stack and wait for the containers to start.

3. Initial Setup Wizard

Once the containers are running:

  1. Go to https://<YOUR-SERVER-IP>:444 in your browser.
  2. Create your Admin account (username and password).
  3. Click on Storage & Database.
  4. Select MySQL/MariaDB.
  5. Fill in the details to match your compose file:
    • Database user: nextcloud
    • Database password: amazingpassword
    • Database name: nextcloud
    • Database host: <YOUR-SERVER-IP>:3336 (Do not use “localhost”, use the actual local IP of your server).

Click Finish Setup. Nextcloud will install.

4. Nginx Proxy Manager & DNS

To access Nextcloud via a nice domain name (e.g., nextcloud.home.arpa) with SSL, we need to configure the proxy.

  1. DNS: Create a DNS record on your router/firewall (like Pi-hole or OPNsense) pointing your desired domain to your Nginx Proxy Manager IP.
  2. NPM: Open Nginx Proxy Manager and create a new Proxy Host.
    • Domain Names: nextcloud.yourdomain.com
    • Forward Host: <YOUR-SERVER-IP>
    • Forward Port: 444
    • Scheme: https
  3. Go to the Advanced tab in the Proxy Host window and paste this to fix upload limits and timeouts:
client_max_body_size 20G;
proxy_read_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
proxy_request_buffering off;
proxy_buffering off;
  1. Go to the SSL tab, request a new certificate (or use your existing one), and click Save.

5. Fixing “Untrusted Domain”

If you try to visit your new domain now, Nextcloud will likely block it with an “Untrusted Domain” error. We need to edit the config file manually.

  1. Go back to Portainer.
  2. Click on the Nextcloud container -> Console -> Connect.
  3. Run the following command to edit the config
nano config/www/nextcloud/config/config.php
  1. Look for the trusted_domains array.
  2. Delete the IP address line and replace it with your domain name, looking something like this:
  'trusted_domains' => 
  array (
    0 => 'nextcloud.yourdomain.com',
  ),
  1. Press Ctrl+X, then Y, then Enter to save.
  2. Restart the Nextcloud container.

You can now access your private cloud securely via your custom domain!

Video Guide

If you prefer a visual walkthrough, check out my YouTube video on this topic:

One thought on “The Easiest Way to Install Nextcloud on Portainer”
  1. Hallo und guten Tag,
    Ihre Anleitung zur Installation von Nextcloud hat bis zum Menü für die eigentliche Installation sehr gut funktioniert. Doch hier hakt es. Im Fenster Database-host habe ich 192.168.178.55:3336 eingesetzt und erhalte die Fehlermeldung: Error while trying to create admin account: An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user ‘nutzer’@’172.20.0.1’ (using password: YES)
    Gebe ich einen anderen Port an erhalte von nginx den Fehler 504 und ein Timeout.
    Bitte helfen Sie eienem Rentner auf die Sprünge. Bin für jede Hilfe dankbar.

Leave a Reply

Your email address will not be published. Required fields are marked *