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
Note: some of this information is outdated, check a newer release here
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
https://<rpi_ip_or_url>
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{1,3}(.\d{1,3}){3}' | 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.
$ 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.
- ownyourbits/miniraspbian is a really tiny raspbian base image that I created following the basic techniques described in this earlier post. Only 52 MB!
- ownyourbits/lamp-arm sits on top of ownyourbits/miniraspbian and provides apache, php and mysql in an additional 285 MB layer.
- ownyourbits/nextcloudpi provides NextCloud, adding another 138 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
Im gonna start from a fresh install again. should i download this? or should i install first the nextcloud 11 from previous post?
Well, this is at this moment less feature complete so if you are in doubt use the NextCloudPi 12 full images.
I don’t see container populating mounted directory from host on rpi 2. What are the user permissions required for host directory so that it can be use by running container ?
Hi,
Please, ask any technical questions in the forums or report problems in github.
You can check if your question has been already answered here
Also, you can talk with the community in the forums.
Please help I can’t create a user when I installed show me this on my pi
https://ibb.co/eRobMa
Hi, please ask technical questions in the forums, or report issues on github. That way other people with the same issue can benefit from the answer.
Check first that it has not been asked before
I hat it to ask for eta but do you consider to update your docker version to the newer changes that you have in the Image version? (Webinterface / Extras / Stretch)
I use this version because I need it in background of my already configured PI with GUI, pilight, Kodi and and …
Honestly, I can’t tell for sure. Maybe a month or so. I have to update miniraspbian, which is the base image for the docker container. I have a lot of work also with the regular version already because of things that I had to adjust after moving to Stretch.
In the end, my final goal is to focus more on the docker container than the SD card, and that is why I rushed the web interface, but it is a lot to handle for a single person. Help is welcome
thank you for your answer,
I am a newbie with linux… took me some time to get Jessie and and where it is…
With your very user friendly guides here it was easy to install docker and NC *thumbs up*
would be nice to see someone with sufficient knowledge helping you
Hi, when I use this docker image I get:
docker logs -f nextcloudpi
/run-parts.sh: line 43: /etc/services-enabled.d/010lamp: Permission denied
/run-parts.sh: line 43: /etc/services-enabled.d/020nextcloud: Permission denied
Init done
Any ideas?
Thank you
please, use the forums for questions
This tutorial seems to be aimed at people with moderate linux and docker experience. However, the overall project is aimed at making nextcloud accessible to the most non-technical users. I realise there might be practical limits to this but here are some improvements I’d suggest.
“Change the following line (adjust accordingly)
/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -g /media/USBdrive/docker -H fd://
”
This is not so helpful to those who don’t know “according” to what.
This would be a reasonable thought process for a newbie:
“I found out that my usb drive is under media and it is not named USBdrive so the tutorial probably expects me to change that bit to the name of mine. But what about the “/docker” bit? Do I have to make a folder with that name? Do I have to make a drive partition with that name? Is it ok to use a different name?”
An even less experienced but observant user may reasonably ask “Where it says “\usr…” should I change it to my username?” and they may even try to execute the line in the terminal, not noticing or realising the code snippet frame is shorthand for “go and edit the file at /lib/systemd/system/docker.service”
This is all reasonable shorthand for an audience with some experience in linux but it would be good if it were not the only instruction set available for newbies who want to do such a common thing as store their nextcloud data on an external drive.
Thanks for writing it nevertheless. 🙂
Please update this post since the container ownyourbits/nextcloudpi doesn’t exist anymore. The name has changed to ownyourbits/nextcloudpi-armhf.
On ownyourbits/nextcloudpi-armhf docker page, I notice a typo. In the description, the architecture should be ARM not x86
Hello,
Thanks for the heads up. If you read the first line of the post, it says that this information is outdated, and there is a link to a newer post.
Cheers
Hi,
I’m new to docker and docker swarm ( what want to setup and learn)..
Can i use this script in combination with docker swarm ??
Docker swarm:
1 raspberry pi 2 > master boot from sd to hdd 120 GB with NOOBS
4 raspberry pi 3 > node boot from sd to hdd 200 GB with NOOBS
The docker swarm is running ok and i want to add 1 raspberry pi 4 >>>
1 raspberry pi 4 8GB and boot from HDD 2 TB for o.a. Nextcloud and Nextcload DATA.
The raspberry pi 4 is now using the ownyourbits Nextcloud arm version. 🙂