How to build a private cloud on Raspberry Pi with ownCloud

Build a private, file sharing cloud, with ownCloud on Raspberry Pi. Step-by-Step guide

In this article we explain, step by step, how to use your Raspberry Pi to create a private cloud where you can store, manage and share files — just like Google Drive or iCloud — but hosted locally, securely, and fully under your control, with no costs.

We’ll use ownCloud for this project and show you how to install it and take your first steps. For advanced customization and extra features, consult ownCloud’s official documentation and community forums.

What you’ll need for this project

  • A Raspberry Pi — we’ll use our Pi Hack carrier board built for the Compute Module 5.
  • External NVMe SSD (recommended). Not required, but strongly recommended for capacity, reliability and durability. If you’re using a Raspberry Pi, consider an SSD kit that mounts directly to the board.
  • Monitor, keyboard and network connection (wired recommended). We use the Ethernet port with PoE to provide both power and connectivity to our Pi Hack.

You can run the entire process directly on the Pi if you are using a keyboard and monitor, SSH from your computer or via Raspberry Pi Connect. Either way, the steps are the same.

Quick start. initial commands

  1. First, make sure your system is up to date:
    sudo apt update
    sudo apt upgrade -y
  2. Download and install Docker:
    curl -sSL https://get.docker.com | sh
  3. Once Docker is installed, add your user to the Docker group so you can interact with Docker without sudo:
    sudo usermod -aG docker $USER
  4. Reboot the device:
    sudo reboot
  5. Verify your user is in the Docker group:
    groups
    You should see docker listed among the groups in the command output.
  6. Verify Docker is working by running the test container:
    docker run hello-world

Important note: assign a static IP to your Raspberry Pi

Before continuing, we strongly recommend assigning a static IP to your Raspberry Pi. If your router or network restarts, a dynamic IP could change and break your access. For any Raspberry Pi used as a server — whether you are building a NAS server, deploying a self-hosted multimedia cloud with Immich, or setting up a full LAMP web server as shown in our previous guides — assigning a static IP address is essential to avoid future headaches.

Create the working directory

Create the directory that will host the ownCloud stack:
sudo mkdir -p /opt/stacks/owncloud

Enter that directory:
cd /opt/stacks/owncloud

Create the Docker Compose file

Now we’ll set up the Docker Compose file. This file will instruct Docker to configure the services required by ownCloud, including MariaDB and Redis.

Create and edit the file:
sudo nano compose.yaml

Inside the editor, copy and paste the following code exactly:
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:
- ${OWNCLOUD_FILES_LOCATION}:/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

Save (Ctrl + O, then Y) and exit (Ctrl + X).

Create the environment file

Next we create the environment file that contains the configuration values for the stack (admin user, passwords, IP, etc.).

Create the file:
sudo nano .env

In this file paste the following and replace the placeholders with your values:

OWNCLOUD_VERSION=VERSION
OWNCLOUD_DOMAIN=DOMAINORIP:HTTPPORT
OWNCLOUD_TRUSTED_DOMAINS=DOMAINORIP
ADMIN_USERNAME=ADMINUSERNAME
ADMIN_PASSWORD=ADMINPASSWORD
HTTP_PORT=HTTPPORT
OWNCLOUD_FILES_LOCATION=MOUNTPATH

Explanations for the placeholders

  • <VERSION> — The ownCloud version you want to run on your Raspberry Pi. Using latest is fine, but you can also pick a specific version.
  • <DOMAINORIP> — The address you’ll use to access the ownCloud instance. For a local-only install, use the Pi’s LAN IP (e.g. 192.168.1.23). If you plan to expose the server remotely, use an external IP or domain name. You can list multiple addresses for OWNCLOUD_TRUSTED_DOMAINS separated by commas: 192.168.1.23,your.piurl.com. Note: multiple domains/IPs apply only to OWNCLOUD_TRUSTED_DOMAINS.
  • <HTTPPORT> — The port ownCloud will listen on. We recommend ports like 8080 to avoid conflicts.
  • <ADMINUSERNAME> — Admin username (used only for the initial setup). You cannot change it later without specific steps.
  • <ADMINPASSWORD> — Admin password used for the initial setup (change it later in the web UI).
  • <MOUNTPATH> — Path where ownCloud data will be stored. Using ./data keeps data within /opt/stacks/owncloud in this example; you can change it to any path that suits your storage layout.

Example .env for this guide

Use the following as an example (customize values to your setup before running):

OWNCLOUD_VERSION=latest
OWNCLOUD_DOMAIN=192.168.6.242:8080
OWNCLOUD_TRUSTED_DOMAINS=192.168.6.242
ADMIN_USERNAME=blackdevice
ADMIN_PASSWORD=blackdevice
HTTP_PORT=8080
OWNCLOUD_FILES_LOCATION=./data

Save (Ctrl + O, then Y) and exit (Ctrl + X).

Start the ownCloud stack

Once everything is in place, initialize the ownCloud server stack:
docker compose up -d

This command will start all services defined in compose.yaml.

Connect to your ownCloud instance

Using a browser tab on your computer, connected to the same network, open the Pi’s IP and port, for example:
http://192.168.6.242:8080

You’ll land on ownCloud’s login screen. Use the admin username and password you set in the .env file. After logging in you can start uploading and organizing files immediately. Explore the dashboard to create folders, add users, and configure shared storage and user permissions.

ownCloud’s documentation and community forums offer many guides for advanced customization, but with this setup your private cloud is already online and ready for local use — perfect for a home or small office.

Next steps and ideas

This is only the beginning, the initial set up. From here you can:

  • Install ownCloud client apps for mobile devices (iOS/Android) and desktops.
  • Configure secure remote access (reverse proxy + TLS, or VPN).
  • Automate backups.
  • Add additional ownCloud apps and tweak performance (Redis tuning, database optimization).

We’d love to see your setup — share your DIY projects and tell us how you use it.

If you enjoy projects like this, check our blog and subscribe to our YouTube channel where we publish video versions of these tutorials and Raspberry Pi DIY projects.

Subscribe to get updates from blackdevice