How to Deploy ownCloud – File Sharing Platform

Updated on 18 December, 2025
Deploy ownCloud File Sharing Platform with Docker Compose, Traefik TLS, and Secure Cloud Storage.
How to Deploy ownCloud – File Sharing Platform header image

ownCloud is an open-source file-sharing platform that allows you to securely store, share, and access your files from anywhere. It serves as a private alternative to services like Dropbox or Google Drive, providing you with full control over your data.

This article demonstrates how to deploy ownCloud on Ubuntu 24.04 using Docker Compose.

Prerequisites

Before you begin:

Set Up the Directory Structure and Environment Variables

ownCloud requires persistent storage for user files and the database, as well as configuration for the domain and administrative credentials. This section prepares the necessary directory structure and sets the required environment variables.

  1. Create the project folders.

    console
    $ mkdir -p ~/owncloud/{files,mysql,redis,letsencrypt}
    
    • files - Stores the actual user data and uploaded files.
    • mysql - Persistent storage for the MariaDB database.
    • redis - Data persistence for Redis cache.
    • letsencrypt - Stores Traefik ACME certificates.
  2. Navigate to the root ownCloud directory.

    console
    $ cd ~/owncloud
    
  3. Create an .env file to store your configuration.

    console
    $ nano .env
    
  4. Add the following values:

    ini
    OWNCLOUD_DOMAIN=owncloud.example.com
    ADMIN_USERNAME=admin
    ADMIN_PASSWORD=STRONG_ADMIN_PASSWORD
    
    DB_PASSWORD=STRONG_DB_PASSWORD
    DB_ROOT_PASSWORD=STRONG_ROOT_PASSWORD
    
    LETSENCRYPT_EMAIL=admin@example.com
    

    Replace the placeholders with your own values:

    • owncloud.example.com – Your actual domain name.
    • STRONG_ADMIN_PASSWORD – The password you will use to log in to the web interface.
    • STRONG_DB_PASSWORD – Secure password for the ownCloud database user.
    • admin@example.com – Your email for SSL certificate notifications.

    Save and close the file.

Deploy with Docker Compose

This section deploys the full ownCloud stack behind Traefik. The configuration includes services for the application, database, and cache.

  1. Add your user account to the docker user group.

    console
    $ sudo usermod -aG docker $USER
    
  2. Apply the new group membership.

    console
    $ newgrp docker
    
  3. Create the Docker Compose manifest file.

    console
    $ nano docker-compose.yml
    
  4. Add the following contents:

    yaml
    services:
      traefik:
        image: traefik:latest
        container_name: traefik
        restart: unless-stopped
        environment:
          DOCKER_API_VERSION: "1.44"
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.websecure.address=:443"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--certificatesresolvers.le.acme.httpchallenge=true"
          - "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
          - "--certificatesresolvers.le.acme.email=${LETSENCRYPT_EMAIL}"
          - "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - ./letsencrypt:/letsencrypt
    
      mariadb:
        image: mariadb:10.11
        container_name: owncloud_db
        restart: unless-stopped
        environment:
          MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
          MYSQL_USER: owncloud
          MYSQL_PASSWORD: ${DB_PASSWORD}
          MYSQL_DATABASE: owncloud
        volumes:
          - ./mysql:/var/lib/mysql
        healthcheck:
          test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
          interval: 10s
          timeout: 5s
          retries: 3
    
      redis:
        image: redis:latest
        container_name: owncloud_redis
        restart: unless-stopped
        volumes:
          - ./redis:/data
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
          interval: 10s
          timeout: 5s
          retries: 3
    
      owncloud:
        image: owncloud/server:latest
        container_name: owncloud_server
        restart: unless-stopped
        depends_on:
          mariadb:
            condition: service_healthy
          redis:
            condition: service_healthy
        environment:
          OWNCLOUD_DOMAIN: ${OWNCLOUD_DOMAIN}
          OWNCLOUD_DB_TYPE: mysql
          OWNCLOUD_DB_NAME: owncloud
          OWNCLOUD_DB_USERNAME: owncloud
          OWNCLOUD_DB_PASSWORD: ${DB_PASSWORD}
          OWNCLOUD_DB_HOST: mariadb
          OWNCLOUD_ADMIN_USERNAME: ${ADMIN_USERNAME}
          OWNCLOUD_ADMIN_PASSWORD: ${ADMIN_PASSWORD}
          OWNCLOUD_REDIS_ENABLED: "true"
          OWNCLOUD_REDIS_HOST: redis
        volumes:
          - ./files:/mnt/data
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.owncloud.rule=Host(`${OWNCLOUD_DOMAIN}`)"
          - "traefik.http.routers.owncloud.entrypoints=websecure"
          - "traefik.http.routers.owncloud.tls=true"
          - "traefik.http.routers.owncloud.tls.certresolver=le"
          - "traefik.http.services.owncloud.loadbalancer.server.port=8080"
    

    Save and close the file.

    This Docker Compose file deploys ownCloud behind Traefik, uses MariaDB for storage and Redis for caching. Each service has a specific purpose:

    owncloud service

    • Runs the official owncloud/server image.
    • Connects to the mariadb service for database storage and redis for caching session data and managing file locks.
    • Uses environment variables to automatically configure the database connection and create the initial administrator account.
    • Persists user files and configuration in the ./files directory (mounted to /mnt/data).
    • Exposes port 8080 internally, which Traefik routes to via the labels section.

    mariadb service

    • Runs MariaDB 10.11 as the database backend.
    • Initializes the owncloud database and user credentials defined in your .env file.
    • Stores database files in the ./mysql directory.
    • Includes a health check to ensure the database is ready before the ownCloud application starts.

    redis service

    • Runs a Redis server to handle caching, which significantly improves ownCloud's performance and responsiveness.
    • Stores cache data in the ./redis directory.

    traefik service

    • Listens on ports 80 and 443 to handle incoming web traffic.
    • Automatically requests and renews SSL certificates from Let’s Encrypt for your ${OWNCLOUD_DOMAIN}.
    • Redirects all insecure HTTP traffic to HTTPS.
  5. Start all services in detached mode.

    console
    $ docker compose up -d
    
  6. Check the container status.

    console
    $ docker compose ps
    
    Note
    For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.

Access ownCloud

  1. Open your web browser and visit your domain https://owncloud.example.com.

  2. The login screen appears. Enter the ADMIN_USERNAME and ADMIN_PASSWORD you configured in your .env file.

  3. Upon successful login, the ownCloud dashboard loads. You can now begin uploading files, creating users, and installing apps from the marketplace.

    Dashboard

Conclusion

By following this article, you successfully deployed ownCloud on Ubuntu 24.04 using Docker Compose. Your file-sharing platform is now accessible over HTTPS and ready for use. For more information, refer to the ownCloud Documentation.

Comments