Skip to main content

1. How to Install Nextcloud

Nextcloud is a fantastic self-hostable piece of software that provides all the expected functions of a cloud storage provider such as OneDrive or Google Drive

There are many ways of installing nextcloud. It can be installed bare metal, directly onto the OS, or it can be installed via docker.

Today, we will be installing nextcloud through docker.

To begin with, open your browser, and log into your portainer instance:

portainer_home_page.JPG

 

Press on local and navigate to Templates, and then click on Custom Templates.

Then, click on Add Custom Template

Enter a name, and don't edit the default settings

In the text box, Copy and Paste the Following:

version: '3.3'
services:
  nextcloud:
    container_name: nextcloud
    image: nextcloud:latest
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=nextclouddb
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=nextcloud
      - MYSQL_HOST=db
      - NEXTCLOUD_ADMIN_USER=ncadmin
      - 'NEXTCLOUD_ADMIN_PASSWORD=changethispassword'
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - 'REDIS_HOST_PASSWORD=nextcloud_redis_pass'
    ports:
      - '8080:80'
      - '443:443'
    links:
      - db
      - redis
    depends_on:
      - db
      - redis
    volumes:
      - '/<pathtonextcloudconfig>:/var/www/html'
      - '/ExtHarddrivemount:/mnt/mainexthdd'
    
  db:
    container_name: ncdb
    image: mariadb:latest
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=nextclouddb
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=nextcloud
      - 'MYSQL_ROOT_PASSWORD=nextcloud_super_super_super_secure'
    volumes:
      - '/<pathtodatabase>:/var/lib/mysql'
    
  redis:
    container_name: ncredis
    image: redis
    restart: unless-stopped
    command: redis-server --requirepass nextcloud_redis_pass


  cron:
    image: rcdailey/nextcloud-cronjob
    restart: always

    depends_on:
      - nextcloud

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - NEXTCLOUD_CONTAINER_NAME=nextcloud

    
networks:
  default:
    name: nextcloud
    driver: bridge

Edit the volume mounts to your desired paths, and change the password to something very secure.

Ensure the NEXTCLOUD_ADMIN_PASSWORD environment variable has a super strong and secure password because this will be the password of your account!!!

And then click on Create Custom Template.

And with that, you have successfully created your own portainer stack template! Proceed to the next page to see how to install it.