How to get started with NCP docker

Docker has been discontinued for the time being, please read the announcement here: NextcloudPi planning to discontinue its docker version with nc 25

The following text is only valid for older installations and is intended as an information archive.

Install Docker

Quick Edit: For users of Raspbian on raspberry devices, please install using the script at https://get.docker.com

Use this only once and without prior docker installation, afterwards use the package manager

Here is the docker documentation explaining this, scroll up to the top and read down for more info


I used the docker documentation for Debian which worked fine, but you’ll find instructions for other Linux flavors, MacOS and Windows there too.

Download and start

The x86 version of NextCloudPi docker container features the latest Nextcloudpi networking and system management extras.

Download it with:

  1. docker pull ownyourbits/nextcloudpi (Should now work for all architectures) Leaving the original pull commands below, just in case, they can be used with :version, if older versions are needed
  • docker pull ownyourbits/nextcloudpi-x86
  • docker pull ownyourbits/nextcloudpi-armhf (If using RPI ot other armfs SBC)
Run it with:
  • docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /path/to/ncdata:/data --name nextcloudpi ownyourbits/nextcloudpi DOMAIN
DOMAIN should be your trusted domain: the URL or IP that will be used to access.

Any folder can be used instead of the volume ncdata to hold the Nextcloud data. Without full PATH ncdata will be in /var/lib/docker/volumes/ of the host.

Optionally for nc-backups you can insert:

  • -v /path/on/your/host/to/ncp-backups:/path/inside/the/container/to/ncp-backups
That's it. Visit https://DOMAIN//activate/ copy and save auto generated passwords, and start using your Nextcloud instance.

Check and manage

Check for and list running containers with:
  • docker ps
Check for and list created containers with:
  • docker ps -a
Stop, start and remove an existing container
  • docker stop nextcloudpi
  • docker start nextcloudpi
  • docker rm nextcloudpi

Update to latest NCP version with:

  • Edit: For docker it's recommended to update by pulling the new image, stopping the old & starting the new, then removing the old else they will start to pile up after a while. And not use the internal updater for ncp, the docker image must be updated in the docker registry on the docker hub and then you update with that.

Run NCP-config to access all NCP apps with:

  • docker exec -it nextcloudpi ncp-config

Make sure container re-start, unless manually stopped with:

  • docker update --restart=unless-stopped nextcloudpi

View other options with:

  • docker help

Start docker with custom storage volume with:

  • sudo mkdir /media/myUsbDrive/ncdata
  • docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/myUsbDrive/ncdata:/data --name nextcloudpi ownyourbits/nextcloudpi sub.domain.tld

Add IP or domain to trusted domains array with:

  • docker exec -it nextcloudpi ncc config:system:set trusted_domains 9 --value="sub.domain.tld"

Reload apache2 webservice with:

  • docker exec -it nextcloudpi service apache2 reload

Docker Commandline Reference

  • https://docs.docker.com/engine/reference/commandline/docker/

Mounting an external drive

As nc-datadir and nc-automount are not available in ncp’s docker image
This is how I mount ncdata persistently.
Preparations:

  • Create a mountpoint for the external drive and ncdata
sudo mkdir /media/ncp
  • Find UUID of external drive
ls -lh /dev/disk/by-uuid/
(Mine looks like this) total 0 lrwxrwxrwx 1 root root 15 Aug 11 09:10 29075e46-f0d4-44e2-a9e7-55ac02d6e6cc -> …/…/mmcblk0p2 lrwxrwxrwx 1 root root 10 Aug 11 09:10 35e98a80-8895-41f4-93e7-39940a1fda70 -> …/…/sda1 lrwxrwxrwx 1 root root 15 Aug 11 09:10 9304-D9FD -> …/…/mmcblk0p1
  • Add a ligne to /etc/fstab
sudo nano /etc/fstab
add line for your drive (copy/paste your drive’s UUID and change ext4 to btrfs if needed):
UUID=YourDrive’sUUID /media/ncp ext4 rw,users,exec 0 0
  • mount the drive
sudo mount -a
Now you can :
  • remove existing container,
docker rm nextcloudpi
  • create a new directory for ncdata as for example
sudo mkdir /media/ncp/ncdata
  • then create and start the container with
docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/ncp/ncdata:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf 192.168.n.nn
  • wait for init done with
docker logs -f nextcloudpi (ctrl+c to exit log)
------------------------------------------------------------------------------

extended quide to getting stared with docker is available on the forum at https://help.nextcloud.com/t/guide-to-getting-started-with-nextcloudpi-docker-in-2020/93396

NOTE



In the NCP Docker container the following NCP Apps are NOT available:

**UPDATES**
- nc-autoupdate-ncp
- nc-update

**BACKUPS**
- nc-restore-snapshot
- nc-snapshot-auto
- nc-snapshot-sync
- nc-snapshot

**CONFIG**
- nc-database
- nc-datadir
- nc-init
- nc-nextcloud

**NETWORKING**
- NFS
- SSH
- nc-static-IP
- samba

**SECURITY**
- UFW
- fail2ban
- nc-audit

**SYSTEM**
- nc-automount
- nc-hdd-monitor
- nc-ramlogs
- nc-swapfile
- nc-zram

**TOOLS**
- nc-format-USB



We hope this doc was helpful, if you encounter any issues please reach out to the community.
These docs are written by volunteers, please consider becoming one of them.
Contact the wiki team at Matrix or Telegram

2 Likes

I have been using Nextcloudpi for more than 4 years. Now I have set up a new Raspi with NCP docker. This article has helped me a lot.

However, I have struggled for over a week against unexplainable HTTP 500 and HTTP 503 errors. Also, the Nextcloudpi container kept stopping itself and not starting automatically after rebooting the Raspi. After a long search, I came across the page How to Fix “No memory limit support” for Docker in Raspberry Pi. Since I added the arguments cgroup_enable=memory swapaccount=1 cgroup_memory=1 cgroup_enable=cpuset to the /boot/cmdline.txt file as recommended on that page, the Nextcloudpi container finally runs fine. Adding this information here on the site as well might help other users with the initial setup of their nextcloudpi container.

1 Like

First things first: This post is super helpful. But in my case I got the following error showing up in the logs after starting my docker container:

Configuring Domain
/usr/local/bin/nextcloud-domain.sh: line 27: /usr/local/bin/ncc: Permission denied

I’m running Ubuntu Server (with Docker) on a Raspberry Pi 4.

  • I mounted an external usb hdd with ext4 file system as described in this post above.
  • I double checked permissions on the mount point and directory structure as statet in this article.

After a week of trial and error I noticed that there is one really important thing:
My Ubuntu mounted the external drive with the flag “noexec”. You can check this if you type “mount” without options in the terminal. After some research this should be the default behaviour if you set the flag “users”. But if this flag is set the docker container will fail all executions of scripts as the error shows - even though the permissions of the mount point allow execution.

You can solve this problem by editing /etc/fstab and add “exec” after the option “users”. Maybe it would be a good idea to add this in the post.

1 Like

Very nice post, I previously had manually installed Nextcloud on RPI 4 and was running successfully. I decided to upgrade Ubuntu on RPI4 and it died a miserable death. After a few months I decided to revive my RPI4 using Ubuntu Server 23.04. I now have a Ubuntu Server 23.04 on Rpi4 with NCP installed following your article. Very easy to follow, than my previous attempt. I still need to work on my SSL certifiicate using encrypt, and will need to figure out any DDNS changes since I use epik.com for domain services. Overall very nice and easy to follow. Thanks for your work.

Hi, I’m looking for a set up docker compose file in order to easily edit the parameter that i need too any help?

1 Like