
Nextcloud is an open-source productivity platform that combines file storage with a suite of collaboration tools, including calendars, contacts, and video conferencing. It is designed for privacy and security, giving you full control over your data while offering features similar to those found in Microsoft 365 or Google Workspace.
This article demonstrates how to deploy Nextcloud on Ubuntu 24.04 using Docker Compose.
Before you begin:
nextcloud.example.com, pointing to your server’s public IP address.Nextcloud requires persistent storage for user data and the database, as well as environment variables to configure the installation. This section sets up the necessary directories and configuration file.
Create the project folders.
html - Stores the main Nextcloud application code and user data.mysql - Persistent storage for the MariaDB database.redis - Stores Redis cache snapshots for persistence between restarts.letsencrypt - Stores Traefik ACME certificates.Navigate to the root Nextcloud directory.
Create an .env file to store your configuration.
Add the following values:
Replace the placeholders with your own values:
nextcloud.example.com – Your actual domain name.STRONG_ADMIN_PASSWORD – The password you will use to log in to the Nextcloud web interface.STRONG_DB_PASSWORD – Secure password for the Nextcloud database user.admin@example.com – Your email for TLS certificate notifications.Save and close the file.
This section deploys the full Nextcloud stack behind Traefik. The configuration includes services for the application, database, and cache.
Add your user account to the docker user group.
Apply the new group membership.
Create the Docker Compose manifest file.
Add the following contents:
Save and close the file.
This Docker Compose file deploys Nextcloud behind Traefik, using MariaDB for structured data and Redis for caching. Each service has a specific purpose:
nextcloud service
nextcloud image.mariadb service for the database and redis for transactional file locking and caching.NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD variables provided../html directory (mounted to /var/www/html).nextcloud-dav) to handle CalDAV and CardDAV redirects, ensuring calendar and contact syncing works correctly.mariadb service
READ-COMMITTED transaction isolation)..env file../mysql directory.redis service
./redis directory.traefik service
Start all services in detached mode.
Check the container status.
For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.
By default, Nextcloud restricts access to localhost to prevent header poisoning attacks. To access the site via your domain name, you must add it to the trusted list.
Configure your domain as a trusted domain using the command below. Replace nextcloud.example.com with your actual domain name.
--user www-data: Runs the command as the web server user.nextcloud: Target service name defined in the docker-compose file.occ: Nextcloud's command-line administration tool.Run the following command to enable HTTPS for all generated links using Nextcloud, which prevents the Service from getting stuck in a login loop.
Open your browser and visit https://nextcloud.example.com. Enter the NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD you configured in your .env file.
Upon successful login, the Nextcloud dashboard loads.
You have successfully deployed Nextcloud on Ubuntu 24.04 using Docker Compose. Your deployment is now secure and accessible over HTTPS. For more details on managing your instance, visit the Nextcloud Administration Manual.
0 Comments
Be the first to comment and share your perspective with the community.