Skip to main content

Docker - Nextcloud

tip

You can find prebuilt images Here

Nextcloud Installation using Docker Compose

This method includes Redis and MariaDB

First lets update your system.

sudo apt-get update && apt-get upgrade -y

Setting up the directories

Now lets setup the Directories

note

You can change the directories to your liking.

sudo mkdir /var/docker && sudo mkdir /var/docker/nextcloud

Lets take ownership of the directory

sudo chown -R 1000:1000 /var/docker

Creating .env files

Now lets make two Docker Secrets files in the new directory.

cd /var/docker/nextcloud
nano .mariadb.env

Paste this using CTRL+SHIFT+V

MYSQL_ROOT_PASSWORD=CHANGEME
MYSQL_PASSWORD=CHANGEME
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
Info

Please Change CHANGEME to a password of your choosing.

danger

Refrain from using Special characters for you MySQL Passwords.
Ex. ‘ ~ ! @ # $ % ^ & * ( ) _ - + = { } [ ] / < > , . ; ? ' : | (space)

Save the new file by pressing CTRL+X

Now lets make the second file.

nano .nextcloud.env

Paste the Following

NEXTCLOUD_TRUSTED_DOMAINS=cloud.<YourDomain>.com
TRUSTED_PROXIES=<IP address of your Reverse Proxy>
OVERWRITEPROTOCOL=https
OVERWRITECLIURL=https://cloud.<YourDomain>.com
REDIS_HOST=redis
REDIS_PORT=6379
PHP_MEMORY_LIMIT=512M
PHP_UPLOAD_LIMIT-100M
MYSQL_PASSWORD=CHANGEME
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_HOST=mariadb
Info

Please Change the Domain and Reverse Proxy IP.

warning

Please make sure that the Password is the same as the one you previously set in the last file

Remove all instances of <>

Creating the Compose file

Now lets create the compose file.

nano docker-compose.yaml

Paste this into the file

name: nextcloud

services:
mariadb:
image: mariadb:10.6
container_name: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- ./mariadb:/var/lib/mysql
env_file:
- .mariadb.env

nextcloud:
image: nextcloud:production
container_name: nextcloud
restart: always
ports:
- 8080:80
links:
- mariadb
- redis
volumes:
- ./nextcloud:/var/www/html
env_file:
- .nextcloud.env

redis:
container_name: redis
image: redis:latest
expose:
- 6379
command: redis-server --save 60 1 --loglevel warning
restart: always

watchtower:
container_name: watchtower
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock

Starting Nextcloud

Now lets start it up.

sudo docker compose up -d
info

the -d flag stands for detatched mode.

After its done pulling the docker images you can open up a web browser.

note

Before proceeding, you will need to configure your reverse proxy. I have an example Nginx config Here.

Connect to nextcloud by typing in your configured domain

You should see this screen.

Nextcloud First Start

Account Creation

Now create an admin account and click Install

Click Install Recommended Apps

Nextcloud Install Recommended Apps

When its done installing you should see your Dashboard

Nextcloud Dashboard

Checking for errors and warnings

On the top right click the User Icon and go to Administration Settings

Nextcloud Administration Settings

Here you should see Security & Setup Warnings

Nextcloud Warnings

In order to fix the Maintenance Window and the Phone Region warnings, we will have to edit our config.php file.

Modifying the config.php file

Run the following command to open the config.php file with nano.

nano nextcloud/config/config.php
Hint

If you recieved an error Directory nextcloud doesnt exist, then you need to change directories.

Run cd /var/docker/nextcloud then try again.

Now add the following to the bottom of the file.

  'maintenance_window_start' => 1,
'default_phone_region' => 'US',

Nextcloud config.php

Now if you go back to your Administration Settings Page.

It should look something like this.

Nextcloud No Warnings

HINT

In some cases, you may have to delete your browser cache and restart the browser for the Warnings to update.

Creating production use user

Now you can go create a user for yourself.

Go to the user icon on the top right and select Users.

Nextcloud Users

Click on Add User on the left hand side.

Nextcloud Add Users

Now create your User.

Caution

Make sure to set Groups to admin

Nextcloud Add Users1

Congragulations!! you have installed Nextcloud!

Troubleshooting

For troubleshooting, please visit Troublshooting.

Comment at the bottom of this page if you need help or have any suggestions to improve this site