Nextcloud is open source software that allows anyone to self-host their own private cloud server.

This guide is aimed at Ubuntu 20.04 but will it work with most Linux distros.

What we'll do

  • Install Nextcloud on docker
  • Fix the configuration to authenticate on the mobile app

Prerequisites


Install

  1. Grab a coffee ☕
  1. Update Linux
    sudo apt update && sudo apt upgrade
  1. Make sure you have docker-compose installed
    sudo apt install docker-compose
  1. Make the directories for the volumes

cd - Go to the home dir
sudo mkdir nextcloud
cd nextcloud
sudo mkdir data
cd data

sudo mkdir html
sudo mkdir config
sudo mkdir apps
sudo mkdir data
sudo mkdir themes
sudo mkdir mysql
cd .. - Go back to the nextcloud dir

  1. Create docker-compose.yaml file

Use the following as a template:

version: '3' 

services:
  nextclouddb:
    image: mariadb
    container_name: nextcloud-mariadb
    volumes:
      - nextcloud-mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    networks:
      default:
        ipv4_address: 10.10.10.4
    environment:
      - MYSQL_ROOT_PASSWORD=STONGPASSWORD
      - MYSQL_PASSWORD=STONGPASSWORD
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  nextcloudapp:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      default:
        ipv4_address: 10.10.10.5
    volumes:
      - nextcloud-html:/var/www/html
      - nextcloud-config:/var/www/html/config
      - nextcloud-apps:/var/www/html/custom_apps
      - nextcloud-data:/var/www/html/data
      - nextcloud-themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

volumes:
  nextcloud-html:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/html
           o: bind
  nextcloud-config:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/config
           o: bind
  nextcloud-apps:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/apps
           o: bind
  nextcloud-data:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/data
           o: bind
  nextcloud-themes:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/themes
           o: bind
  nextcloud-mysql:
     driver_opts:
           type: none
           device: /home/USER/nextcloud/data/mysql
           o: bind
networks:
  default:
    external:
      name: dockernet

Replace:
10.10.10.4 and 10.10.10.5: Use a relevant docker network IP
STRONGPASSWORD: A nice and strong password
USER: Your linux username

  1. Start the docker containers
    sudo docker-compose up -d
  1. Set up the Reverse Proxy
Nginx Proxy Manager Example
  1. Head to the WebUI

Create your admin account
Select MySQL/MariaDB and enter the details used in the docker-compose file
nextcloud-setup

You should now be welcomed to Nextcloud:

Nextcloud Welcome Screen
  1. Fix the "Grant access" issue/bug with the Nextcloud App. This is an issue with the Reverse Proxy using HTTPS.

sudo nano /home/USER/nextcloud/data/config/config.php

Add: 'overwriteprotocol' => 'https',
Just before 'trusted_domains' =>

It should look similar to this:
nextcloud-configphp

You should now be able to sign in using the Nextcloud App.

All done!