Installing ownCloud as a Docker Container on Raspberry Pi

In recent years, cloud services for storing documents online, such as Dropbox, Google Drive and Amazon Drive, have become increasingly popular.
With these services, users can store their files in the cloud and access them at any time, as long as they have an internet-connected device (PC, tablet or smartphone).

Despite the benefits these services offer, users often worry about the reliability of their chosen cloud hosting provider. A common criticism is that customers don’t know who else has access to their stored data, or whether it is really deleted from the server once removed. This is particularly important when storing sensitive data.

However, if you want full control over your data, you can create and manage your own personal cloud with ownCloud.
ownCloud is well-established, free and easy-to-use software developed for exactly this purpose, and in this guide we will set up our own personal cloud storage on a Raspberry Pi.

Cloud storage is a cloud computing model in which data is stored on remote servers and managed by a cloud storage provider. This allows users to manage their data and share it with friends and family over the internet.

To access your files remotely, you need a public IP address or, alternatively, a DDNS service that lets you reach your network through a domain name (here is a guide to using DuckDNS), and you must have forwarded the necessary ports on your router to the Raspberry Pi (in this tutorial I will use TCP port 48080).

With that said, we can proceed with installing and configuring ownCloud as a Docker container. Of course, you will need a Raspberry Pi with its operating system installed (preferably the Lite version, so that all resources are dedicated to the required services) and with Docker and Docker Compose installed (here is the installation guide).

Connect to your Raspberry Pi via SSH and create a new folder that will contain all the files needed for the new container.

mkdir /home/pi/ownCloud

Move into this folder and then create the docker-compose.yml file, which will contain the instructions needed to create the container. In fact, ownCloud needs two additional containers to work, Redis and MySQL, and we will also include the commands to create these two containers in the docker-compose.yml file.

cd /home/pi/ownCloud
sudo nano docker-compose.yml

and enter the following:

version: '2.1'
volumes:
   files:
     driver: local
   mysql:
     driver: local
   backup:
     driver: local
   redis:
     driver: local
services:
   owncloud:
     image: owncloud/server:${OWNCLOUD_VERSION}
     restart: always
     ports:
       - ${HTTP_PORT}:8080
     depends_on:
       - db
       - redis
     environment:
       - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
       - OWNCLOUD_DB_TYPE=${OWNCLOUD_DB_TYPE}
       - OWNCLOUD_DB_NAME=${OWNCLOUD_DB_NAME}
       - OWNCLOUD_DB_USERNAME=${OWNCLOUD_DB_USERNAME}
       - OWNCLOUD_DB_PASSWORD=${OWNCLOUD_DB_PASSWORD}
       - OWNCLOUD_DB_HOST=${OWNCLOUD_DB_HOST}
       - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
       - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
       - OWNCLOUD_MYSQL_UTF8MB4=${OWNCLOUD_MYSQL_UTF8MB4}
       - OWNCLOUD_REDIS_ENABLED=${OWNCLOUD_REDIS_ENABLED}
       - OWNCLOUD_REDIS_HOST=${OWNCLOUD_REDIS_HOST}
     healthcheck:
       test: ["CMD", "/usr/bin/healthcheck"]
       interval: 30s
       timeout: 10s
       retries: 5
     volumes:
       - ./files:/mnt/data
   db:
     image: webhippie/mariadb:latest
     restart: always
     environment:
       - MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
       - MARIADB_USERNAME=${OWNCLOUD_DB_USERNAME}
       - MARIADB_PASSWORD=${OWNCLOUD_DB_PASSWORD}
       - MARIADB_DATABASE=${OWNCLOUD_DB_NAME}
       - MARIADB_MAX_ALLOWED_PACKET=128M
       - MARIADB_INNODB_LOG_FILE_SIZE=64M
     healthcheck:
       test: ["CMD", "/usr/bin/healthcheck"]
       interval: 30s
       timeout: 10s
       retries: 5
     volumes:
       - ./mysql:/var/lib/mysql
       - ./backup:/var/lib/backup
   redis:
     image: webhippie/redis:latest
     restart: always
     environment:
       - REDIS_DATABASES=1
     healthcheck:
       test: ["CMD", "/usr/bin/healthcheck"]
       interval: 30s
       timeout: 10s
       retries: 5
     volumes:
       - ./redis:/var/lib/redis

Once you have pasted the text, close the file by pressing CTRL+X, then type Y (or S, depending on your system language) and finally press ENTER to confirm.

Now we need to create another file called ownCloud_env, which will contain the credentials the ownCloud container uses to access the database, as well as the credentials for MariaDB

sudo nano ownCloud_env

and enter the following:

OWNCLOUD_DOMAIN=pincopallo.duckdns.org:48080     #modificare con il proprio nome di dominio e scegliere una porta che verrà utilizzata per accedere alla pagina web di ownCloud
OWNCLOUD_DB_TYPE=mysql                  #lasciare invariato
OWNCLOUD_DB_NAME=owncloud               #nome del database utilizzato da ownCloud
OWNCLOUD_DB_USERNAME=owncloud           #nome dell'utente utilizzato da ownCloud per accedere al db
OWNCLOUD_DB_PASSWORD=owncloud           #password dell'utente utilizzato da ownCloud per accedere al db
OWNCLOUD_DB_HOST=db                     #lasciare invariato... è il nome del container per il DB
OWNCLOUD_ADMIN_USERNAME=admin           #nome dell'utente admin
OWNCLOUD_ADMIN_PASSWORD=admin           #password per l'utente admin
OWNCLOUD_MYSQL_UTF8MB4=true             #lasciare invariato...
OWNCLOUD_REDIS_ENABLED=true             #lasciare invariato...
OWNCLOUD_REDIS_HOST=redis               #lasciare invariato...
MARIADB_ROOT_PASSWORD=owncloud          #password dell'utente root all'interno del database

Once you have pasted and edited the text, close the file by pressing CTRL+X, then type Y (or S, depending on your system language) and finally press ENTER to confirm.

Next, we will create another (hidden) file containing further sensitive data

sudo nano .env

and enter the following:

OWNCLOUD_VERSION=10.7
OWNCLOUD_DOMAIN=pincopallo.duckdns.org:48080     #modificare con  il proprio nome di dominio e scegliere una porta che verrà utilizzata per accedere alla pagina web di ownCloud
ADMIN_USERNAME=admin                    #nome dell'utente admin
ADMIN_PASSWORD=admin                    #password per l'utente admin
HTTP_PORT=48080                         #porta TCP dove verrà pubblicata la pagina web di ownCloud

again, once you have pasted and edited the text, close the file by pressing CTRL+X, then type Y (or S, depending on your system language) and finally press ENTER to confirm.

Before running the command to create the containers, we need to download and install a package required for ownCloud to work properly, so type:

wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb

and once the installation has finished, you can remove the downloaded package with the following command:

sudo rm libseccomp2_2.5.1-1_armhf.deb

Now we can run the following command to install ownCloud with the specified parameters:

docker-compose up -d

Once the docker-compose command has finished, wait a few minutes and then try accessing the ownCloud web interface by opening a web browser on your computer and typing the following in the address bar:

http://[IP-DEL-TUO-RASPBERRY-PI]:48080

Enjoy!

Enjoy!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top