How to Deploy ownCloud - An Opensource File-sharing Application and Alternative to Google Drive

Updated on 29 May, 2025
Learn how to deploy ownCloud with Docker on Ubuntu 24.04 for secure, self-hosted file sharing and syncing.
How to Deploy ownCloud - An Opensource File-sharing Application and Alternative to Google Drive header image

ownCloud is an open-source file-sharing platform that enables you to store, sync, and manage files from a self-hosted server. It offers a privacy-focused alternative to cloud services like Google Drive and Dropbox by giving you full control over your data and infrastructure.

In this article, you will deploy ownCloud on an Ubuntu 24.04 server using Docker. You’ll set up a MariaDB database container, secure your environment, access the ownCloud web interface, and explore features such as file sharing, user management, and app integration.

Prerequisites

Before you begin:

  • Have access to an Ubuntu 24.04 instance as a non-root sudo user.
  • Create a domain A record that points to your server’s IP address. For example, cloud.example.com.

Install ownCloud Using Docker Compose

Docker Compose provides a structured way to manage multi-container applications like ownCloud. This method allows you to define services, networks, and volumes in a single file and manage them together with simple commands.

Install Docker Compose

  1. Update your APT package index.

    console
    $ sudo apt update
    
  2. Install Docker.

    console
    $ sudo apt install docker.io -y
    
  3. Enable and start Docker.

    console
    $ sudo systemctl enable docker
    
    console
    $ sudo systemctl start docker
    
  4. Add your user to the docker group to avoid using sudo with every command.

    console
    $ sudo usermod -aG docker $USER
    

    Log out and log back in to apply the change.

  5. Install the new Docker Compose plugin.

    console
    $ mkdir -p ~/.docker/cli-plugins
    
    console
    $ curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
    
    console
    $ chmod +x ~/.docker/cli-plugins/docker-compose
    
  6. Verify the installation.

    console
    $ docker compose version
    

    Output should be similar to:

    Docker Compose version v2.X.X

Deploy ownCloud with Docker Compose

  1. Create a project directory and switch into it.

    console
    $ mkdir ~/owncloud
    
    console
    $ cd ~/owncloud
    
  2. Create a docker-compose.yml file.

    console
    $ nano docker-compose.yml
    
  3. Add the following configuration to define the ownCloud and MariaDB services:

    yaml
    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 # minimum required ownCloud version is 10.9
        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
    

    Replace environment values like securepassword with secure production credentials.

  4. Start the containers using Docker Compose.

    console
    $ docker compose up -d
    
  5. Check that both services are running.

    console
    $ docker compose ps
    

    Output should show both the owncloud and db containers as Up.

Configure ownCloud

After deploying ownCloud with Docker Compose, secure and optimize it for production use with HTTPS, a reverse proxy using Nginx, and proper firewall configuration.

Configure Nginx as a Reverse Proxy

  1. Install Nginx if it’s not already installed.

    console
    $ sudo apt update
    
    console
    $ sudo apt install nginx -y
    
  2. Create a configuration file for ownCloud.

    console
    $ sudo nano /etc/nginx/sites-available/owncloud
    
  3. Paste the following, replacing cloud.example.com with your domain:

    ini
    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;
       }
    }
    
  4. Enable the configuration.

    console
    $ sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/
    
    console
    $ sudo nginx -t
    
    console
    $ sudo systemctl reload nginx
    

Allow Nginx Through the Firewall

  1. Open HTTP and HTTPS ports.

    console
    $ sudo ufw allow 'Nginx Full'
    
    console
    $ sudo ufw reload
    

Secure ownCloud with HTTPS

  1. Install Certbot and the Nginx plugin.

    console
    $ sudo apt install certbot python3-certbot-nginx -y
    
  2. Generate and apply a TLS certificate.

    console
    $ sudo certbot --nginx -d cloud.example.com
    

    Certbot will automatically edit your Nginx config to enable HTTPS.

Enable Automatic Renewal

  1. Ensure Certbot renewal is scheduled.

    console
    $ sudo systemctl enable certbot.timer
    
  2. Test the renewal process.

    console
    $ sudo certbot renew --dry-run
    

Verify Setup

Open your browser and navigate to:

https://cloud.example.com

You should see the ownCloud setup wizard served securely over HTTPS.

Access and Set Up ownCloud

Complete the final setup through the ownCloud web interface:

  1. Open your browser and visit your domain over HTTPS.

    https://cloud.example.com
  2. The ownCloud setup wizard will appear.

  3. Create an admin account by choosing a secure username and password.

  4. Under Database Configuration, enter the following:

    • Database user: ownclouduser
    • Database password: the password you used when starting the MariaDB container
    • Database name: owncloud
    • Database host: owncloud-db
  5. Click Finish Setup.

After setup completes, you'll be redirected to the login page. Use your admin credentials to sign in and access the ownCloud dashboard.

Manage and Share Files with ownCloud

After logging into the ownCloud dashboard, you can begin managing your files:

  1. Upload and organize files using the web interface. Drag-and-drop support is available.

  2. Create folders and move files to structure your storage.

  3. Share files or folders via public or private links. You can:

    • Set expiration dates
    • Require passwords
    • Enable or disable editing
  4. Create user groups and set granular permissions for collaboration.

  5. Sync files across devices by installing the ownCloud desktop or mobile clients. These apps automatically synchronize your data between the server and your devices.

ownCloud also supports WebDAV, making it compatible with third-party tools and OS-native file managers.

Install and Manage Apps in ownCloud

Backup and Restore ownCloud Data

To ensure data durability and prevent accidental loss, regularly back up your ownCloud installation. This includes both user files and database content.

Backup with Docker Volumes

If you deployed ownCloud using Docker, your data is typically stored in a named volume like owncloud_files.

  1. Export the ownCloud data volume to a tarball.

    console
    $ docker run --rm \
     -v files:/volume \
     -v $(pwd):/backup \
     alpine \
     tar -czf /backup/owncloud_files_backup.tar.gz -C /volume .
    

    This command saves a .tar.gz backup of the ownCloud volume to the current directory on your host.

  2. Backup the MariaDB data directory (optional but recommended). If using a MariaDB container, you can similarly back up its volume.

    console
    $ docker run --rm \
     -v mysql:/volume \
     -v $(pwd):/backup \
     alpine \
     tar -czf /backup/mariadb_backup.tar.gz -C /volume .
    

Backup Best Practices

  • Perform regular backups (daily or weekly) using a scheduled cron job.
  • Store backups off-server (e.g., to S3, rsync to remote machine).
  • Use snapshot-based backups if deploying with cloud storage.

For production deployments, also consider backing up your docker-compose.yml and .env files if using Docker Compose.

Conclusion

In this article, you deployed ownCloud on an Ubuntu 24.04 server using Docker. You configured a secure MariaDB backend, set up reverse proxy and firewall rules, optionally enabled SSL with Let's Encrypt, and accessed the ownCloud dashboard via the browser. You also explored optional configurations like background cron jobs, app installation, and backup strategies.

With ownCloud, you gain full control over your file storage and collaboration environment, making it a powerful alternative to third-party platforms like Google Drive and Dropbox.

To explore advanced features or troubleshoot issues, refer to the official documentation:

Comments

No comments yet.