Skip to main content
shopping_basket Basket 0

Raspberry Pi 4 Personal Datacentre Part 1: Ansible, Docker and Nextcloud

Andrew Back
Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.


March 24, 2020 14:18

How do you do updates of NextCloud with this type of installation?

0 Votes

March 27, 2020 09:35

@Henry13 Ah, that's super easy. You stop the container and then delete it with "docker rm nextcloud". Then re-run the Ansible playbook and because this has the line "pull: yes", it will pull the latest version of the Nextcloud container image down before re-creating the container. Any config/data will be in the ncdata volume and hence is separated from the application code.


February 3, 2020 13:38

  • Moderated

Hey, a nice general intro to Ansible on a Pi, thanks.

Going slightly out of scope, if I set: docker_install_compose: TRUE
implying it also installs docker-compose though, it errors out. is that because pip is "pip v2" and not v3? Any hints to fix?

I guess though I'll force it in now and play with it all, and then see how to debug playbooks later. Thanks!

0 Votes

November 21, 2019 08:22

thanks for this post, its exactly what I was looking for. will order a rpi 4 today, already have a big usb hard drive I can use for this.

November 21, 2019 09:59

@firehopper enjoy! Run into any problems and let me know.

November 23, 2019 10:05

@Andrew Back okay, doing the docker logs nextcloud thing says it can't find / not found so I dont think I did something right. and going to nas.local just pops up a Initializing NextCloudPi for the first time Please wait... and it just sits there.. nothing happens..

November 25, 2019 08:50

@firehopper oops, my bad! Just updated the nextcloud.yml playbook, as it was pointing to the wrong image (tried a few different ones out...) This is seemingly a known problem with the -armhf one previously referenced, which is a simpler container without the additional web admin interface on :4443. So you need to update the playbook and then delete the container and its data volume with: $ docker stop nextcloud && docker rm nextcloud && docker volume rm ncdata Then just re-run the updated playbook and it will use the correct image this time.

November 25, 2019 08:50

@Andrew Back added a 4443:4443 to the ports setting in the nextcloud playbook. and it works now :)

November 25, 2019 08:50

@firehopper now just need to figure out how to add the hard drive on usb aka /dev/sda

November 25, 2019 08:50

@firehopper you'd need to update /etc/fstab so that it gets mounted at boot time. Then if you inspect the ncdata volume you will see this is mapped to "/var/lib/docker/volumes/ncdata/_data", so on the assumption that all apps will use Docker you could use a mount point of "/var/lib/docker/volumes" (after having copied the contents of this to the root of the drive). Alternatively you could probably mount the drive to a more generic mount point, e.g. /data, and then sym link the Docker volumes root to a sub-directory, e.g. /data/docker. Or maybe update the Docker config to create volumes elsewhere. First approach feels like the cleanest and the others would need some research. Note that there are also other drivers available for volumes. The default is called "local".

[Comment was deleted]

November 26, 2019 16:21

@Andrew Back Hi, Thank you very much for the guide, everything works right from the box! I got a question though, which is bugging me. As i'm learning Docker/Ansible and overall Linux stuff, I managed to get my external USB HDD (NTFS) (its dir is /mnt/mydisk) setup and its working fine. The thing that I cannot understand is how can i get my data always be uploaded there instead of my SD card? What and where do I need to change so that all the data goes into lets say /mnt/mydisk/Nextcloud Thanks again!

November 27, 2019 08:48

@Alex9112 see my earlier response to @firehopper. Easiest way would be to: 1) stop the container; 2) copy the contents of /var/lib/docker/volumes to the external drive; 3) unmount the drive and remount it as /var/lib/docker/volumes; 4) start the container. Then each time you create a new volume, e.g. for additional containers, it would exist on the external drive.

November 27, 2019 08:47

@Andrew Back Thanks for the reply, I will test it out. Do you know if it matters if the external disk is ntfs or it must be ext4? I've been banging my head for the past few days and apparently NTFS will not suffice.

December 2, 2019 08:13

@Alex9112 last I heard I think Linux could read NTFS but not write and even if it can now, I'd avoid it and use ext4 instead.

November 25, 2019 08:50

@Andrew its not the router as far as I can see.. not sure what to do to fix it. the pi is running no gui so I cant try on that. :)

November 25, 2019 08:50

@Andrew Back well it runs and all.. but I cant connect to the 4443 port. Firefox can’t establish a connection to the server at nas.local:4443. it might be the new router. I'm gonna see if I can fix it there.

November 22, 2019 14:12

@Andrew Back thanks, have the pi, and a router with cables, everything is installed, now to follow your instructions and setup the raspberrypi. might get a small 2x20 or something lcd screen and use that to show the IP of the pi. as the router app doesnt show ip addresses of the things on it for some reason. for use to ssh into the pi for controlling it from my pc on the network.

November 23, 2019 10:05

@firehopper Nice idea. Though you should also be able to SSH to it using the hostname, e.g. from another Linux computer and if you haven't changed the hostname, "ssh pi@raspberrypi.local". Not sure if from Windows you don't need the ".local" suffix. In any case, you should be able to use mDNS to connect by name and therefore not need to know the IP.

November 19, 2019 13:21

Ordered a Pi 4 today and looking forward to your next post. Any idea when it will be coming out? Great work!

November 20, 2019 09:16

@Conjada thanks for the kind words! Probably the first or second week in December. Just in the process of figuring out a few final details.

Related Content

DesignSpark Electrical Logolinkedin