Nextcloud: your own Google Drive

Nextcloud it’s a suite of servers and clients that allow you to create a storage cloud based for your data. So we are going to set up a Nextcloud on Docker and publish it online using DuckDNS. In that way, we can manage a home cloud to access and share files from anywhere.


As always we are going to start editing our docker-compose.yaml file:

version: '3.3'

#We need to persist the data
volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    #I had to add this line because it's throws me 
    #an error with the db --skip-innodb-read-only-compressed
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --skip-innodb-read-only-compressed
    volumes:
      - db:/var/lib/mysql
    environment:
      #Use your own secure password for mariadb and the db
      - MYSQL_ROOT_PASSWORD=matiasmercado.ar
      - MYSQL_PASSWORD=matiasmercado
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8081:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=matiasmercado
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db


  duckdns:
    image: linuxserver/duckdns
    container_name: duckdns
    environment:
      - TZ=America/Argentina/Mendoza
      - SUBDOMAINS=blogmatiasm
      # You need to take this token from duckdns website
      - TOKEN=01bffa9f-6350-47e5-92c0-b90238ad0701
      - LOG_FILE=false #optional
    restart: always

I had multiple services hosting on my home server, thats why I’m using port 8081, but you can use port 80/443 (if you dont have any other service running on that port).

Then we can test and install nextcloud. Open a new tab and ingress the serverIP:8081. Should look like this:

It’s going to ask us to create a new admin account. Select wherever you like and click on “Install”. After a few seconds Nextcloud is going to ask for recommended apps, I don’t want any, so I just click on “Cancel”:

Now we are on the Dashboard of Nextcloud, we are going to find some default files, like photos and text, videos and manuals of Nextcloud. We can delete on “Files” tab on top left folder icon.


Access from internet

Now we are going to set everything to access from internet. First thing to do is follow the DuckDNS guide I already post here. There we are going to see how to make a dynamic IP “static” with a DynDNS free server. If you already have a static IP or a cloud server, you can skip this part. I set the port 8081 for Nextcloud, so we need to open that port:

I’m using a Mikrotik Router, configuration via winbox.

Now if you are trying to enter Nextcloud from your phone app or website, and you have a home server like me, Nexcloud is going to notice that you don’t have a secure connection. It’s because we are trying to enter to our “domian.duckdns.org:8081” without a proper SSL cert installed. This time we are going to let this domain unsecure, but in a next post we are going to find out how to install make a website secure with Docker and Let’s Encrypt. To open Nextcloud via HTTP, we are going to edit config.php

# nano /path/to/nextcloud/volumen/_data/config/config.php

We need to find the section that say ‘trusted_domains’ and add the DuckDNS domain:

  'trusted_domains' =>
  array (
    0 => 'casa.ar:8081', #local DNS
    1 => 'matiasm.duckdns.org:8081', #DuckDNS 
  ),

Phone App

After downloading the Android/iOS app, we are going to add our server:

Here we are going to add “http://domain.duckdns.org:8081” or your domain / static IP. If everything it’s okay, then is going to ask for our user and password:

Next, at least on Android, we need to give Nextcloud access to our files:

Allowing Nextcloud access to our phone files
Remember you can delete this defaults files, there are only for test and manuals for Nextcloud use.

And so that it! In this few steps we can make our cloud file server, we can upload and download photos, videos, files, calendars, contacts, mails, and much more. Now you can explore some very interesting options, like shared links, notifications, activities and more.

Leave a Comment

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