{"id":354,"date":"2018-10-16T11:08:38","date_gmt":"2018-10-16T11:08:38","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=354"},"modified":"2018-10-17T08:30:27","modified_gmt":"2018-10-17T08:30:27","slug":"nextcloudpi-docker-for-raspberry-pi-own-your-bits","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/16\/nextcloudpi-docker-for-raspberry-pi-own-your-bits\/","title":{"rendered":"NextCloudPi docker for Raspberry Pi \u2013 Own your bits"},"content":{"rendered":"<p><em>Note: some of this information is outdated, check a newer release <a href=\"https:\/\/ownyourbits.com\/2017\/11\/15\/nextcloudpi-dockers-for-x86-and-arm\/\">here<\/a><\/em><\/p>\n<p>I would like to introduce my <a href=\"https:\/\/hub.docker.com\/r\/ownyourbits\/nextcloudpi\/\">NextCloud ARM container<\/a> for the Raspberry Pi.<\/p>\n<p>It only weights 475 MB, and it is shares codebase with <a href=\"https:\/\/ownyourbits.com\/2017\/02\/13\/nextcloud-ready-raspberry-pi-image\/\">NextCloudPi<\/a>, so it has the same features:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.raspbian.org\/\">Raspbian<\/a> 9 Jessie<\/li>\n<li><a href=\"https:\/\/nextcloud.com\/\">Nextcloud<\/a> 13.0.1<\/li>\n<li>Apache 2.4.25, with HTTP2 enabled<\/li>\n<li>PHP 7.0<\/li>\n<li>MariaDB 10<\/li>\n<li>Automatic redirection to HTTPS<\/li>\n<li>ACPU PHP cache<\/li>\n<li>PHP Zend OPcache enabled with file cache<\/li>\n<li>HSTS<\/li>\n<li>Cron jobs for Nextcloud<\/li>\n<li>Sane configuration defaults<\/li>\n<li><a href=\"https:\/\/ownyourbits.com\/2017\/03\/25\/nextcloud-a-security-analysis\/\">Secure<\/a><\/li>\n<li><a href=\"https:\/\/ownyourbits.com\/2017\/02\/19\/creating-a-minimal-debian-container-for-docker\/\">Small<\/a>, only 475 MB in disk, 162 MB compressed download.<\/li>\n<\/ul>\n<p>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.<\/p>\n<p>It can be run in any system other that Raspbian, as long as it supports docker.<\/p>\n<p>Some of the extras will be added soon, where it makes sense.<\/p>\n<h4>Installation<\/h4>\n<p>If you haven\u2019t yet, install docker in your Raspberry Pi.<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>curl -sSL get.docker.com | sh<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Adjust permissions. Assuming you want to manage it with the user <em>pi<\/em><\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>sudo usermod -aG docker pi<\/p>\n<p>newgrp docker<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Optionally, store containers in an external USB drive. Change the following line (adjust accordingly)<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>ExecStart=\/usr\/bin\/dockerd -g \/media\/USBdrive\/docker -H fd:\/\/<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Reload changes<\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>systemctl daemon-reload<\/p>\n<p>systemctl restart docker<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You can check that it worked with<\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>$ docker info | grep Root<\/p>\n<p>Docker Root Dir: \/media\/USBdrive\/docker<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Usage<\/strong><\/p>\n<p>The only parameter that we need is the <em>trusted domain<\/em> that we want to allow.<\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>DOMAIN=192.168.1.130 # example for allowing an IP<\/p>\n<p>DOMAIN=myclouddomain.net # example for allowing a domain<\/p>\n<p>docker run -d -p 443:443 -p 80:80 -v ncdata:\/data &#8211;name nextcloudpi ownyourbits\/nextcloudpi $DOMAIN<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>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.<\/p>\n<p>The admin user is <em>ncp<\/em>, and the default password is <em>ownyourbits<\/em>. Login to create users, change default password and other configurations.<\/p>\n<p>Other than that, we could map different ports if we wanted to. Note that a volume <em>ncdata<\/em> will be created where configuration and data will persist.<\/p>\n<p>For example, you could wrap a script like this to allow your current local IP<\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>#!\/bin\/bash<\/p>\n<p># Initial Trusted Domain<\/p>\n<p>IFACE=$( ip r | grep &#8220;default via&#8221; | awk &#8216;{ print $5 }&#8217; )<\/p>\n<p>IP=$( ip a | grep &#8220;global $IFACE&#8221; | grep -oP &#8216;d(.d)&#8217; | head -1 )<\/p>\n<p>docker run -d -p 443:443 -p 80:80 -v ncdata:\/data &#8211;name nextcloudpi ownyourbits\/nextcloudpi $IP<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you ever need direct access to your storage, you can find out where your files are located.<\/p>\n<table>\n<tbody>\n<tr>\n<td>&nbsp;<\/p>\n<p>1<\/p>\n<p>2<\/p>\n<p>3<\/p>\n<p>4<\/p>\n<p>5<\/p>\n<p>6<\/p>\n<p>7<\/p>\n<p>8<\/p>\n<p>9<\/p>\n<p>10<\/p>\n<p>11<\/p>\n<p>12<\/p>\n<p>13<\/p>\n<p>14<\/p>\n<p>15<\/p>\n<p>16<\/p>\n<p>17<\/p>\n<p>18<\/p>\n<p>19<\/p>\n<p>20<\/p>\n<p>&nbsp;<\/td>\n<td>$ docker inspect nextcloudpi<\/p>\n<p>&#8230;<\/p>\n<p>&#8230;<\/p>\n<p>&#8220;Mounts&#8221;: [<\/p>\n<p>{<\/p>\n<p>&#8220;Type&#8221;: &#8220;volume&#8221;,<\/p>\n<p>&#8220;Name&#8221;: &#8220;ncdata&#8221;,<\/p>\n<p>&#8220;Source&#8221;: &#8220;\/media\/USBdrive\/docker\/volumes\/ncdata\/_data&#8221;,<\/p>\n<p>&#8220;Destination&#8221;: &#8220;\/data&#8221;,<\/p>\n<p>&#8220;Driver&#8221;: &#8220;local&#8221;,<\/p>\n<p>&#8220;Mode&#8221;: &#8220;z&#8221;,<\/p>\n<p>&#8220;RW&#8221;: true,<\/p>\n<p>&#8220;Propagation&#8221;: &#8220;&#8221;<\/p>\n<p>}<\/p>\n<p>],<\/p>\n<p>&#8230;<\/p>\n<p>&#8230;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>You can in this way alter your <em>config.php<\/em><\/p>\n<h6>Details<\/h6>\n<p>The container consists of 3 main layers, totalling 476 MB.<\/p>\n<ul>\n<li><a href=\"https:\/\/hub.docker.com\/r\/ownyourbits\/miniraspbian\/\">ownyourbits\/miniraspbian<\/a> is a really tiny raspbian base image that I created following the basic techniques described in <a href=\"https:\/\/ownyourbits.com\/2017\/02\/19\/creating-a-minimal-debian-container-for-docker\/\">this<\/a> earlier post. Only 52 MB!<\/li>\n<li><a href=\"https:\/\/hub.docker.com\/r\/ownyourbits\/lamp-arm\/\">ownyourbits\/lamp-arm<\/a> sits on top of ownyourbits\/miniraspbian and provides apache, php and mysql in an additional 285 MB layer.<\/li>\n<li><a href=\"https:\/\/hub.docker.com\/r\/ownyourbits\/nextcloudpi\/\">ownyourbits\/nextcloudpi<\/a> provides NextCloud, adding another 138 MB.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ownyourbits.com\/wp-content\/uploads\/2017\/06\/ncp-layers-700x1120.png\" alt=\"\" width=\"371\" height=\"566\" \/><\/p>\n<p>A benefit of docker layers is that we can sometimes just update the upper layers, or provide updates on top of the current layout.<\/p>\n<h6>Code<\/h6>\n<p>The <a href=\"https:\/\/github.com\/nextcloud\/nextcloudpi\/tree\/master\/docker\">build code<\/a> is now part of the <a href=\"https:\/\/github.com\/nextcloud\/nextcloudpi\/\">NextCloudPi repository<\/a>.<\/p>\n<p>You can build it yourself in a <a href=\"https:\/\/ownyourbits.com\/2017\/02\/06\/raspbian-on-qemu-with-network-access\/\">Raspbian ARM environment<\/a> with.<\/p>\n<table style=\"font-size: 1rem;\">\n<tbody>\n<tr>\n<td><\/td>\n<td>git clone https:\/\/github.com\/nextcloud\/nextcloudpi.git<\/p>\n<p>make -C nextcloudpi<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/hub.docker.com\/u\/ownyourbits\/\">dockerhub<\/a><\/p>\n<p><a href=\"https:\/\/ownyourbits.com\/2017\/06\/08\/nextcloudpi-docker-for-raspberry-pi\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/16\/nextcloudpi-docker-for-raspberry-pi-own-your-bits\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;NextCloudPi docker for Raspberry Pi \u2013 Own your bits&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":500,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/354\/revisions\/500"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}