docker, nextcloud, raspberrypi

NextCloudPi docker for Raspberry Pi

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.


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

curl -sSL | 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


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=        # example for allowing an IP    # 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


# 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


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.


The build code is now part of the NextCloudPi repository.

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

git clone
make -C nextcloudpi


Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]


  1. Im gonna start from a fresh install again. should i download this? or should i install first the nextcloud 11 from previous post?

  2. 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 ?

  3. 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 …

    1. 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

      1. 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

  4. Hi, when I use this docker image I get:

    docker logs -f nextcloudpi
    / line 43: /etc/services-enabled.d/010lamp: Permission denied
    / line 43: /etc/services-enabled.d/020nextcloud: Permission denied
    Init done

    Any ideas?

    Thank you

  5. 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)

    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. 🙂

  6. 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

  7. 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. 🙂

Leave a Reply to nachoparker Cancel reply

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