Short and clear: which type of Nextcloud installation should I choose - LXC, VM or Docker?
Nextcloud is a popular solution for creating your own cloud data storage. In this article, we will look at various ways to install Nextcloud, their pros and cons. To begin with, there are several ways to install Nextcloud: directly on the server, in a virtual machine, in Docker manually or in Docker via the automatic AIO stack. You can also install Nextcloud in an LXC container.
Manual installation in Docker is the most common option that requires the administrator to have basic knowledge of working with containers. Allows you to work with persistent configuration files by dropping them into a container. The main advantage of installing Nextcloud in a Docker container is the ease of installation and management (link to the official repository, there is also a Docker Compose file there: https://github.com/nextcloud/docker). You don't need to install a large number of packages manually, as is the case with LXC containers.
However, this method has its drawbacks: the complexity of setting up a reverse proxy, the complexity of limiting resources per container, removing logs and not a convenient update process, which can be difficult for untrained users. In addition, installing and replacing basic packages, such as PHP or PHP-FPM, separately from the entire container is a difficult task even for an experienced administrator. However, this option may be less productive than LXC due to additional virtualization layers.
Installation in a Docker AIO container is the manufacturer's recommended method
The AIO stack has this name, because during the installation process, one (main) container is created in Docker, which has access to the Docker daemon itself via a socket and independently creates and installs other containers for the operation of the software stack. This is the easiest way to install: all parameters are set via the YAML Docker-compose file (download link: https://github.com/nextcloud/all-in-one/blob/main/compose.yaml), and minimal integration efforts are required from the administrator.
At the same time, from the point of view of security and configuration, this is the most unfortunate option, because firstly, you give access to the Docker itself to a third–party application, and secondly, what is not set in the ENV parameters, you can not fix. Well, or at least, your labors in this regard will be reset after the next update of the platform.
Installation on bare hardware in the Ubuntu operating system
In the case of using weak computers, such as Raspberry Pi, installing Nextcloud based on the operating system may be the most appropriate option, since it allows you to use all the free space on the server disks to store files and does not require virtualization support.
This method of installing Nextcloud does not give obvious advantages, except for access to all free space on the server disks for storing files. To install Nextcloud on the operating system from the official website, you can download the script and run it on the command line.
Installation in an LXC container
Installing in an LXC container is the most unnecessarily difficult option, since container images are delivered in a stripped-down form and you will have to install many packages manually, including language support. The only more or less working LXC image I could find on the Turnkey Linux website (https://www.turnkeylinux.org/nextcloud), but there were difficulties with it during installation. So if you are not a fan of LXC, then it is better to pass by this solution.
In a virtual machine, you can very precisely configure all the packages that Nextcloud uses, such as PHP, Redis and PHP-FPM, by choosing their versions. This allows you to achieve the best performance and resource optimization. You can download as a ready-made virtual machine image for VMware, Hyper-V and Proxmox at the link https://www.hanssonit.se/nextcloud-vm, and use the installation .sh script for Ubuntu 22.04, available here: https://github.com/nextcloud/vm.
- Configuration Management: You can manage all configuration files in one window, which simplifies the process of configuring and updating Nextcloud.
- Backup and recovery: Virtual machines are easier to backup and restore, which allows you to quickly repair the system in case of a failure or an unsuccessful update.
- Snapshots: With the help of snapshots, you can easily roll back the configuration if the update has led to problems.
- Data protection: The virtual machine disk can be easily encrypted, which provides additional protection for your data.
Since the Nextcloud stack is designed to work over the Internet, it is mandatory to set up an HTTPs connection with automatic certificate renewal, delete or rename the account ncadmin/admin and configure other types of locks, for example by GeoIP, IP address range, etc.