How to Install ownCloud on Ubuntu 24.04 Using Docker
ownCloud is an open-source solution for file storage and sharing, allowing you to synchronize, manage, and access your files from a self-hosted server. It serves as a privacy-oriented alternative to popular cloud services like Google Drive and Dropbox by providing you with full control over your infrastructure and data.
This guide explains how to set up ownCloud on an Ubuntu 24.04 server using Docker. You will configure a MariaDB database container, secure the deployment, access the ownCloud web dashboard, and learn about features like file sharing, user management, and application integration.
Prerequisites
Before starting, ensure you have the following:
- An Ubuntu 24.04 server with a non-root sudo-enabled user.
- A domain A record pointing to your server’s IP address, for example cloud.example.com.
Install ownCloud with Docker Compose
Docker Compose simplifies managing applications with multiple services such as ownCloud. It lets you define services, networks, and volumes in a single configuration file and control them with simple commands.
Install Docker Compose
First, update the package index:
$ sudo apt update
Install Docker:
$ sudo apt install docker.io -y
Enable and start the Docker service:
$ sudo systemctl enable docker
$ sudo systemctl start docker
Add your user to the Docker group so you don’t need to prepend sudo
for each command:
$ sudo usermod -aG docker $USER
Log out and back in to apply the group changes.
Next, install the Docker Compose plugin:
$ mkdir -p ~/.docker/cli-plugins
$ curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
$ chmod +x ~/.docker/cli-plugins/docker-compose
Verify the installation:
$ docker compose version
The output should display a version string, such as:
Docker Compose version v2.X.X
Deploy ownCloud with Docker Compose
Create a project directory and navigate into it:
$ mkdir ~/owncloud
$ cd ~/owncloud
Create the docker-compose.yml
file:
$ nano docker-compose.yml
Add the following configuration to define the ownCloud, MariaDB, and Redis services:
version: "3"
volumes:
files:
driver: local
mysql:
driver: local
redis:
driver: local
services:
owncloud:
image: owncloud/server:${OWNCLOUD_VERSION}
container_name: owncloud_server
restart: always
ports:
- ${HTTP_PORT}:8080
depends_on:
- mariadb
- redis
environment:
- OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
- OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS}
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=owncloud
- OWNCLOUD_DB_USERNAME=owncloud
- OWNCLOUD_DB_PASSWORD=owncloud
- OWNCLOUD_DB_HOST=mariadb
- OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
- OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
- OWNCLOUD_MYSQL_UTF8MB4=true
- OWNCLOUD_REDIS_ENABLED=true
- OWNCLOUD_REDIS_HOST=redis
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- files:/mnt/data
mariadb:
image: mariadb:10.11
container_name: owncloud_mariadb
restart: always
environment:
- MYSQL_ROOT_PASSWORD=owncloud
- MYSQL_USER=owncloud
- MYSQL_PASSWORD=owncloud
- MYSQL_DATABASE=owncloud
- MARIADB_AUTO_UPGRADE=1
command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- mysql:/var/lib/mysql
redis:
image: redis:6
container_name: owncloud_redis
restart: always
command: ["--databases", "1"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- redis:/data
Update environment variables such as securepassword with strong, production-ready credentials.
Start the containers:
$ docker compose up -d
Check the container status:
$ docker compose ps
The output should confirm that both ownCloud and MariaDB are running.
Configure ownCloud
After deployment, secure the setup for production by enabling HTTPS, configuring a reverse proxy with Nginx, and setting proper firewall rules.
Set Up Nginx as a Reverse Proxy
Install Nginx if not already present:
$ sudo apt update
$ sudo apt install nginx -y
Create a new Nginx site configuration:
$ sudo nano /etc/nginx/sites-available/owncloud
Paste this configuration, replacing cloud.example.com with your own domain:
server {
listen 80;
server_name cloud.example.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable the site and reload Nginx:
$ sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl reload nginx
Allow Firewall Access
Permit HTTP and HTTPS traffic through UFW:
$ sudo ufw allow 'Nginx Full'
$ sudo ufw reload
Secure ownCloud with HTTPS
Install Certbot with the Nginx plugin:
$ sudo apt install certbot python3-certbot-nginx -y
Generate and apply a Let’s Encrypt TLS certificate:
$ sudo certbot --nginx -d cloud.example.com
Certbot will automatically update your Nginx configuration to enable HTTPS.
Enable Certificate Renewal
Ensure automatic renewal is active:
$ sudo systemctl enable certbot.timer
Test the renewal process:
$ sudo certbot renew --dry-run
Verify Your Setup
Open your browser and go to:
You should now see the ownCloud setup wizard running securely over HTTPS.
Access and Set Up ownCloud
Finalize the installation using the ownCloud web interface:
- Open your browser and go to your domain over HTTPS: https://cloud.example.com.
- The setup wizard will appear.
- Create an administrator account by selecting a secure username and password.
- For the database settings, provide the following details:
- Database user: ownclouduser
- Database password: the password configured for the MariaDB container
- Database name: owncloud
- Database host: owncloud-db
Click Finish Setup. Once the process is done, you’ll be redirected to the login page. Use your admin credentials to sign in and access the ownCloud dashboard.
Inside the dashboard, you can start managing your files:
- Upload and organize files through the web interface, with drag-and-drop functionality.
- Create folders and move files to structure your storage.
- Share files or folders with public or private links. Options include:
- Setting expiration dates
- Requiring passwords
- Allowing or disabling editing
- Create user groups and define permissions for collaborative work.
- Install the ownCloud desktop or mobile clients to sync files across devices. These automatically synchronize data between the server and your devices.
- Use WebDAV for compatibility with third-party tools and OS-native file managers.
Install and Manage Apps in ownCloud
ownCloud features an App Marketplace to extend functionality with extra modules.
Access the Marketplace
- Sign in as an administrator.
- Click the Apps icon in the top navigation bar.
- Browse or search apps by category, such as productivity, storage, authentication, or multimedia.
Enable an App
- Click Enable next to the desired app.
- Some apps may require additional configuration.
Popular Apps
- Calendar – Schedule and share events.
- Contacts – Manage and sync address books.
- External Storage – Connect with Dropbox, Google Drive, S3, or local mount points.
Manage Installed Apps
- Check the Enabled tab to view or disable active apps.
- Some apps provide settings accessible in the Admin section under Settings.
Refer to the official documentation for configuration details or developing custom apps.
Backup and Restore ownCloud Data
To protect against data loss, perform regular backups of both user files and database content. If you used Docker for deployment, data usually resides in named volumes like owncloud_files
.
Backup the Data Volume
Export the ownCloud volume to a compressed tarball:
$ docker run --rm \
-v files:/volume \
-v $(pwd):/backup \
alpine \
tar -czf /backup/owncloud_files_backup.tar.gz -C /volume .
This saves a .tar.gz
backup of the ownCloud volume in the current host directory.
Backup the MariaDB Data Volume
Backing up the MariaDB volume is also recommended:
$ docker run --rm \
-v mysql:/volume \
-v $(pwd):/backup \
alpine \
tar -czf /backup/mariadb_backup.tar.gz -C /volume .
Restore Data
To restore, create fresh volumes if necessary:
$ docker volume create files
$ docker volume create mysql
Extract the backup into the volume:
$ docker run --rm \
-v files:/volume \
-v $(pwd):/backup \
alpine \
tar -xzf /backup/owncloud_files_backup.tar.gz -C /volume
Apply the same process to the MariaDB volume to restore database content.
Backup Best Practices
- Automate backups daily or weekly using cron jobs.
- Store backups offsite (e.g., S3 or remote servers via rsync).
- Use snapshot-based backups if using cloud storage.
- Also back up
docker-compose.yml
and.env
files for production environments.
Conclusion
This guide showed how to deploy ownCloud on Ubuntu 24.04 with Docker, configure MariaDB, set up Nginx and firewall rules, and secure it with SSL certificates. You also learned how to access the dashboard, manage apps, and implement backup strategies.
With ownCloud, you maintain full control of your file storage and collaboration environment, providing a robust alternative to third-party platforms like Google Drive and Dropbox.