NextCloud

Overview

Nextcloud is a self-hosted file storage and collaboration platform that provides cloud storage, file synchronization, calendar, contacts, and office integration similar to Google Drive or OneDrive.

Item Value
Image nextcloud
Port 52046 mapped to 80
Database MariaDB
Volumes nextcloud_data, nextcloud_db

Docker Compose Files

docker-compose.yaml file

---
services:
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - nextcloud_db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}

  app:
    image: nextcloud
    restart: always
    ports:
      - 52046:80
    depends_on:
      - db
    volumes:
      - nextcloud_data:/var/www/html
    environment:
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_HOST=db
volumes:
  nextcloud_db:
  nextcloud_data:

Environment Variables .env file

MYSQL_ROOT_PASSWORD=strongrootpassword  
MYSQL_DATABASE=nextcloud  
MYSQL_USER=nextcloud  
MYSQL_PASSWORD=strongpassword 

Post-Deployment

Once you have NextCloud deployed and running we will need to setup the trusted domains, so if you use a reverse proxy you will be able to access nextcloud from your custom url.

Note: Complete the initial setup wizard before modifying config.php. The file is generated during the first-time installation.

Open up a terminal in your Docker machine where nextcloud is running and we need to find the name of the Nextcloud container by running

docker ps

once you have the correct name we will need to open a shell inside that container

docker exec -it <nextcloud-container-name> bash

Now we should be ready to edit the configuration which should be in /var/www/html/config/config.php

apt update && apt install -y nano   # only if nano isn't already installed
nano /var/www/html/config/config.php

Next we will need to find the trusted_domains section

'trusted_domains' =>
array (
  0 => 'localhost',
),

and change it to your needs

'trusted_domains' =>
array (
  0 => 'localhost',
  1 => 'nextcloud.example.com',
  2 => '192.168.1.100',
),

Save and Exit