1. Creating a Custom Nextcloud Template
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:
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.
Extra Info:
Breakdown of the docker compose stack:
- Nextcloud is the main container running the nextcloud app
- MariaDB is the database container with which nextcloud talks to store data
- Redis is an optional container that sits between the nextcloud and the mariadb app as a cache layer speeding up database queries from nextcloud
- Nextcloud_Cron_Job is container to run some daily maintenance scripts on the nextcloud containers
Although there are four different containers, the nextcloud container communicates with the database containers, as nextcloud will not work without a database.
The Nextcloud-Cron-Job container communicates with main nextcloud container itself.
All four containers are in the same network nextcloud thus they are able to communicate with each other. The fact that they are in the same docker compose/stack file, will lead the containers to being put in the same network nevertheless. The final four lines underĀ networks
is so that name of network is something neat like nextcloud
and not a random string of letters.