Manually deploy your own cloud repository using Nextcloud

Tram Ho

I’m sure that you’ve used, more or less, one of the cloud storage services like Google Drive, One Drive, or Dropbox , … Thanks to these services, you can access files anywhere Anywhere, on any device, easily share and work with others, or simply a layer of defense in case data stored on the device gets lost.

Nextcloud is also a piece of software that helps create a cloud storage system. The difference is that Nextcloud is completely open source and free . That’s why anyone can use Nextcloud to create their own cloud storage!

So why must choose Nextcloud instead of the “big” like Google Drive? This is mostly up to everyone’s taste, but basically deploying Nextcloud yourself gives you full control over your data, from the pain of privacy issues , and the level of prices will probably be even cheaper.

In this article, I would like to join you to deploy a complete Nextcloud system via Docker, Docker Compose, Mariadb and Caddyserver v2 .


First of all, to start installing Nextcloud, you need to have the following available:

  • Domain arbitrary
  • VPS with temporary configuration and enough capacity to use (or maybe a Raspberry Pi at home)
  • Basic knowledge of linux server administration and working with docker, docker-composse.

In the article, I will expect that your server / VPS has all the necessary tools available (docker, docker-compose, …). If you haven’t already, you can see instructions for installing docker here and installing docker-compose here .

Perform setup with docker-compose

Folder tree

Once the installation is complete, your directory tree just created will look like this:

Create file docker-compose.yml

In this file docker-compose.yml , I will set up 3 services: nextcloud , mariadb and caddy .

I choose to use the nextcloud image file in the FPM format. Because this nextcloud image file does not contain Apache (or any other web server), I choose to install Caddyserver v2 to do reverse proxy. Here, I choose Caddyserver instead of Nginx because Caddy has a short config file and can automatically install and renew SSL.

I choose to use Mariadb as the database for Nextcloud. Some other database types supported by nextcloud that you can choose are SQLite or PostgreSQL.

For the data to be “survived” after each deletion and re-creation of the container, I use the named volume of Docker with the volume names: nextcloud_data, mariadb_data, caddy_data, caddy_config.

The final docker-compose.yml file is written as follows:

Declare environment variables

You then need to declare environment variables. Create the .env file in the same folder as the docker-compose.yml file and add the following data accordingly:

Caddyserver settings

In the caddy directory, you need to create 2 files named Dockerfile and Caddyfile .

The Dockerfile file is used to create an image file of Caddyserver with its configs:

The Caddyfile file contains configs for Nextcloud:

Download and install the containers

The job is only to run a single command.

Once it’s finished running, (hopefully) Nextcloud has been successfully installed and available at your chosen domain name!

Too long, afraid to do?

If you are afraid to follow the step-by-step instructions, just clone the preconfigured git repo as instructed above:

Then you just need to correct the information in the .env file accordingly and run the command:

That’s it!

Use Nextcloud

When you first access Nextcloud, you will be greeted with the admin account settings screen:

Install Nextcloud admin account

After entering the username and password of the desired admin account, Nextcloud will begin the installation automatically in about 1-2 minutes. Right after that, you can start using Nextcloud:

Nextcloud interface

Nextcloud also has a full range of apps for Windows, Linux, macOS, Android, iOS , … The apps all support folder sync capabilities no different from Google Drive, along with the ability to sync calendar, contacts, … as well as the ability to view many popular file formats and much more. To install the Nextcloud app on your devices, go to and follow the instructions.


Share the news now

Source : Viblo