Self-hosted Nextcloud instance using Docker Compose with MariaDB and Adminer, deployed on a Synology NAS.
| Section | Description | |
|---|---|---|
| βοΈ | PREREQUISITES | Software requirements |
| π | REQUIRED DIRECTORIES | Host directories to create |
| π | STACK OVERVIEW | Services, ports and network |
| π | ENVIRONMENT VARIABLES | stack.env configuration |
| π’ | PORTAINER DEPLOYMENT | Deploy via Portainer |
| ποΈ | BACKUP | Volumes to back up |
| π | LICENSE | MIT License |
- π³ Docker installed on your host machine
- π’ Portainer (recommended for deployment via Git)
- π Access to your host machine to create directories (via SSH or file manager)
Create the following directories on your host before deploying:
mkdir -p /volume1/docker/nextcloud/custom_apps
mkdir -p /volume1/docker/nextcloud/config
mkdir -p /volume1/docker/nextcloud/data
mkdir -p /volume1/docker/nextcloud/themesNote
Paths above are configured for Synology NAS. Adjust the NEXTCLOUD_HOST_* variables in Portainer to match your host environment.
Three services orchestrated via Docker Compose, communicating through a shared bridge network.
| Service | Image | Container | Container Port | Host Port | Network | Depends On | Description |
|---|---|---|---|---|---|---|---|
mariadb |
mariadb:latest | nextcloud-mariadb |
3306 |
β | backend-nextcloud |
β | Database server |
adminer |
adminer:latest | nextcloud-adminer |
8080 |
8081 |
backend-nextcloud |
mariadb |
Database administration interface |
nextcloud |
nextcloud:latest | nextcloud |
80 |
8443 |
backend-nextcloud |
mariadb |
File hosting and collaboration platform |
Note
The Nextcloud image includes an Apache web server β no separate web server container is needed.
All variables must be provided via stack.env or manually in the Portainer stack environment section.
| Variable | Description | Required |
|---|---|---|
MYSQL_DATABASE |
Database name | β |
MYSQL_USER |
Database username | β |
MYSQL_PASSWORD |
Database password | β |
MYSQL_ROOT_PASSWORD |
Database root password | β |
NEXTCLOUD_ADMIN_USER |
Nextcloud admin username β configuration still being evaluated | β |
NEXTCLOUD_ADMIN_PASSWORD |
Nextcloud admin password β configuration still being evaluated | β |
NEXTCLOUD_TRUSTED_DOMAINS |
Allowed domains (space-separated) β configuration still being evaluated | β |
NEXTCLOUD_THEME_DIR_NAME |
Nextcloud theme directory name | β |
ADMINER_DESIGN |
Adminer UI theme (e.g. dracula) |
β |
NEXTCLOUD_HOST_CUSTOM_APPS_DIR |
Host path for custom apps | β |
NEXTCLOUD_HOST_CONFIG_DIR |
Host path for config | β |
NEXTCLOUD_HOST_DATA_DIR |
Host path for user data | β |
NEXTCLOUD_HOST_THEMES_DIR |
Host path for themes | β |
Tip
If NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD are not set, the admin account will be created manually on first login.
Deploy this stack via Portainer using the Git repository integration.
- Open Portainer β Stacks β Add stack
- Select Repository
- Set the following fields:
| Field | Value |
|---|---|
| Repository URL | https://github.com/xamayca/Nextcloud-docker |
| Compose path | compose.yaml |
Enable GitOps updates to automatically redeploy when changes are detected in the Git repository.
Warning
GitOps updates may override any manual configuration changes.
Option A β Import file
Download stack.env from the repository and import it directly into Portainer.
Option B β Manual setup Copy the variables into the Advanced environment variables section.
Important
Verify the following before deploying.
Database β required, MariaDB will not start without these
-
MYSQL_DATABASE,MYSQL_USER,MYSQL_PASSWORD,MYSQL_ROOT_PASSWORDare all set
Bind mount paths β directories must exist on the host before deploying
-
NEXTCLOUD_HOST_CUSTOM_APPS_DIRβ e.g./path/to/nextcloud/custom_apps -
NEXTCLOUD_HOST_CONFIG_DIRβ e.g./path/to/nextcloud/config -
NEXTCLOUD_HOST_DATA_DIRβ e.g./path/to/nextcloud/data -
NEXTCLOUD_HOST_THEMES_DIRβ e.g./path/to/nextcloud/themes
Optional β review or leave empty
-
NEXTCLOUD_ADMIN_USER/NEXTCLOUD_ADMIN_PASSWORDβ if not set, admin account must be created manually on first login -
NEXTCLOUD_TRUSTED_DOMAINSβ defaults tolocalhost, set your host IP or domain to allow external access -
NEXTCLOUD_THEME_DIR_NAMEβ if not set, no custom theme is mounted -
ADMINER_DESIGNβ if not set, defaults to the standard Adminer theme
Click Deploy the stack.
This stack uses Docker volumes for persistent storage.
| Volume | Type | Host path | Container path |
|---|---|---|---|
mariadb_data |
Docker volume | β | /var/lib/mysql |
html |
Docker volume | β | /var/www/html |
apps |
Bind mount | /volume1/docker/nextcloud/custom_apps |
/var/www/html/custom_apps |
config |
Bind mount | /volume1/docker/nextcloud/config |
/var/www/html/config |
data |
Bind mount | /volume1/docker/nextcloud/data |
/var/www/html/data |
theme |
Bind mount | /volume1/docker/nextcloud/themes/<optional_theme_name> |
/var/www/html/themes/<optional_theme_name> |
Warning
This section is currently under review. Backup strategy may change in future updates.
This project is licensed under the MIT License β see the LICENSE file for details.
