NextCloudPi docker for Raspberry Pi – Own your bits

Note: some of this information is outdated, check a newer release here

I would like to introduce my NextCloud ARM container for the Raspberry Pi.

It only weights 475 MB, and it is shares codebase with NextCloudPi, so it has the same features:

  • Raspbian 9 Jessie
  • Nextcloud 13.0.1
  • Apache 2.4.25, with HTTP2 enabled
  • PHP 7.0
  • MariaDB 10
  • Automatic redirection to HTTPS
  • ACPU PHP cache
  • PHP Zend OPcache enabled with file cache
  • HSTS
  • Cron jobs for Nextcloud
  • Sane configuration defaults
  • Secure
  • Small, only 475 MB in disk, 162 MB compressed download.

With this containerization, the user no longer requires to start from scratch in order to run NextCloud in their RPi, as opposed from flashing the NextCloudPi image. It also opens new possibilities for easy upgrading and sandboxing for extra security.

It can be run in any system other that Raspbian, as long as it supports docker.

Some of the extras will be added soon, where it makes sense.

Installation

If you haven’t yet, install docker in your Raspberry Pi.

curl -sSL get.docker.com | sh

Adjust permissions. Assuming you want to manage it with the user pi

sudo usermod -aG docker pi

newgrp docker

 

Optionally, store containers in an external USB drive. Change the following line (adjust accordingly)

ExecStart=/usr/bin/dockerd -g /media/USBdrive/docker -H fd://

Reload changes

systemctl daemon-reload

systemctl restart docker

You can check that it worked with

$ docker info | grep Root

Docker Root Dir: /media/USBdrive/docker

Usage

The only parameter that we need is the trusted domain that we want to allow.

DOMAIN=192.168.1.130 # example for allowing an IP

DOMAIN=myclouddomain.net # example for allowing a domain

docker run -d -p 443:443 -p 80:80 -v ncdata:/data –name nextcloudpi ownyourbits/nextcloudpi $DOMAIN

After a few seconds, you can access from your browser just typing the IP or URL in the navigation bar of your browser. It will redirect you to the HTTPS site.

The admin user is ncp, and the default password is ownyourbits. Login to create users, change default password and other configurations.

Other than that, we could map different ports if we wanted to. Note that a volume ncdata will be created where configuration and data will persist.

For example, you could wrap a script like this to allow your current local IP

#!/bin/bash

# Initial Trusted Domain

IFACE=$( ip r | grep “default via” | awk ‘{ print $5 }’ )

IP=$( ip a | grep “global $IFACE” | grep -oP ‘d(.d)’ | head -1 )

docker run -d -p 443:443 -p 80:80 -v ncdata:/data –name nextcloudpi ownyourbits/nextcloudpi $IP

If you ever need direct access to your storage, you can find out where your files are located.

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

 

$ docker inspect nextcloudpi

“Mounts”: [

{

“Type”: “volume”,

“Name”: “ncdata”,

“Source”: “/media/USBdrive/docker/volumes/ncdata/_data”,

“Destination”: “/data”,

“Driver”: “local”,

“Mode”: “z”,

“RW”: true,

“Propagation”: “”

}

],

 

You can in this way alter your config.php

Details

The container consists of 3 main layers, totalling 476 MB.

A benefit of docker layers is that we can sometimes just update the upper layers, or provide updates on top of the current layout.

Code

The build code is now part of the NextCloudPi repository.

You can build it yourself in a Raspbian ARM environment with.

git clone https://github.com/nextcloud/nextcloudpi.git

make -C nextcloudpi

dockerhub

Source

Leave a Reply

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