3 minutes
Self Hosted Nextcloud Using Docker
As part of my little series of self-hosted web services using Docker, in this article I describe how I installed Nextcloud running behind Traefik as a reverse proxy which is providing an encrypted HTTPS connection. As almost usual, Nextcloud is also providing an official Docker image. This image by itself is not sufficient to have a running Nextcloud instance. What is missing is a web server and a database, similar to the dockerized WordPress.
As a database, I’m using MariaDB and nginx as a web server. The database files are stored “outside” the Docker container to have them persistent when the container stops, crashes or gets deleted. Nextcloud’s files are also stored outside and additionally mounted into the web server’s container.

Setup of Docker containers to run Nextcloud
1. Database
Setting up a MariaDB instance used by Nextcloud does not require special configuration magic. Just specifying the image, storing its data outside the container, setting some credentials and disabling the connection to Traefik.
|
|
nextcloud_db.txt
|
|
2. Nextcloud
My Nextcloud configuration is pretty concise. I just needed to connect the database container, specify a volume for Nextcloud files, put the container into an internal Docker network and disable a connection to Traefik.
|
|
3. Web server
Since both existing containers are not reachable from outside Docker, I need to configure a web server that is accepting incoming connections forwarded by Traefik. Again, there is not much configuration necessary, just the usual suspects. Injecting an nginx configuration file and the Nextcloud files, defining networks and a connection to Traefik.
|
|
Summary
Configuring Nextcloud running in Docker is pretty straightforward. In addition to Nextclouds Docker image, a database to store various metadata and a web server to communicate with Traefik are needed, which are both running in dedicated Docker containers. As mentioned in other posts, the HTTPS encryption is handled by Traefik.