Nextcloud 21 install with Docker Compose on Ubuntu 20.04
Last Updated: 18th July 2021
WARNING: Due to a Nextcloud bug, the mariadb:latest
tag is not compatible with Nextcloud. To fix use the MariaDB docker tag mariadb:10.5
.
Nextcloud is open source software that allows anyone to self-host their own private storage.
This guide is aimed at Ubuntu 20.04 but it will work with most Linux distros.
What we'll do
- Deploy a Nextcloud instance using docker
- Fix the configuration, to authenticate using the mobile app
Prerequisites
- Docker
Ubuntu Guide: https://docs.docker.com/engine/install/ubuntu/
Debian Guide: https://docs.docker.com/engine/install/debian/ - Reverse Proxy e.g. Caddy, NPM or Nginx
Install
- Grab a coffee ☕
- Update Linux
sudo apt update && sudo apt upgrade
- Make sure you have docker-compose installed
sudo apt install docker-compose
- Create your Nextcloud Directory
sudo mkdir nextcloud && cd nextcloud
- Create docker-compose.yaml file
Use the following as a template:
sudo nano docker-compose.yaml
version: '3'
services:
nextclouddb:
image: mariadb:latest
container_name: nextcloud-mariadb
volumes:
- ./data/mysql:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
networks:
default:
ipv4_address: 10.10.10.4
environment:
- MYSQL_ROOT_PASSWORD=CHANGEME
- MYSQL_PASSWORD=CHANGEME2
- 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:
- ./data/html:/var/www/html
- ./data/config:/var/www/html/config
- ./data/apps:/var/www/html/custom_apps
- ./data/data:/var/www/html/data
- ./data/themes:/var/www/html/themes
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
networks:
default:
external:
name: dockernet
Using external storage? Check out this docker-compose.yaml
Replace:
10.10.10.4 and 10.10.10.5: Use a relevant docker network IP
CHANGEME: A nice and strong password
To create a Docker Network:
sudo docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 dockernet
- Start the docker containers
sudo docker-compose up -d
- Set up the Reverse Proxy
Caddy Example:
nextcloud.example.com {
reverse_proxy 10.10.10.5:80
header {
Strict-Transport-Security max-age=31536000;
X-Content-Type-Options nosniff;
X-XSS-Protection "1; mode=block;"
X-Robots-Tag none;
X-Frame-Options SAMEORIGIN;
Referrer-Policy no-referrer;
}
}
- Head to the WebUI
Create your admin account
Select MySQL/MariaDB and enter the details used in the docker-compose file
You should now be welcomed to Nextcloud:
- Fix the "Grant access" issue with the Nextcloud App. This is an issue with the Reverse Proxy using HTTPS.
sudo nano $HOME/nextcloud/data/config/config.php
Add: 'overwriteprotocol' => 'https',
Just before 'trusted_domains' =>
It should look similar to this:
You should now be able to sign in using the Nextcloud App.
All done!