Page 1 of 1

Docker on raspberry pi

Posted: Sunday 02 October 2016 7:11
by thoth
I've been using domoticz inside a docker container on a raspberry pi for a couple of months now. I thought I would mention here in case anyone else might find it useful. There's a repo here:
https://github.com/joshuacox/mkdomoticz

you can checkout the arm branch, and `make run`, it will prompt you for a port which it will forward to port 8080 of the container. It's also possible to build it all locally, first checkout the 'local-stretch' branch, then you'll need this repo too
https://github.com/joshuacox/local-nginx

and `make stretch` to build a local copy of debian from scratch using debootstrap

for a docker ready pi image, I prefer starting here:
https://github.com/luxas/kubernetes-on-arm

he has a script `sdcard/write.sh` which is useful, which will prepare an SD card with docker ready to go on either arch linux or hypriotOS

which is yet another project to watch:
http://blog.hypriot.com/

Cheers! and hope everyone is having as much fun with this stuff as I am!

Re: Docker on raspberry pi

Posted: Sunday 02 October 2016 8:11
by remb0
thanks! I use docker on my synology and it works great.
maybe something for the wiki, would you like to write that?

Re: Docker on raspberry pi

Posted: Sunday 02 October 2016 9:30
by simonrg
Neat, I am ignorant about Docker, what are the advantages of running inside a Docker image? To my simple mind the SD card image is already self-contained and can be backed up.

What am I missing?

Thanks.

Re: Docker on raspberry pi

Posted: Sunday 02 October 2016 10:34
by remb0
Hardware Independent. Easy to Move to other hardware.

Re: Docker on raspberry pi

Posted: Sunday 02 October 2016 23:23
by simonrg
remb0 wrote:Hardware Independent. Easy to Move to other hardware.
Ok still not sure I understand why Docker helps with Domoticz for users.

Domoticz is rather hardware dependent isn't it - what's plugged into which USB / PiFace card etc..

I have now read a couple of introductions to Docker, from which my understanding is that Docker is more software than hardware independent, i.e. Domoticz would be running in an identical software environment because of the Docker image it is part of.

Using a standard SD card image gives Domoticz a standard software environment, so Docker doesn't give any advantage here does it?

I can see that as a Docker image would be a lot smaller than a full SD card image, so for Domoticz this could make complete Domoticz environment updates a lot easier to distribute than SD card images.

Have I got it now?

Re: Docker on raspberry pi

Posted: Monday 03 October 2016 5:30
by thoth
Well the advantage in my case is that eventually I want to move most services into an orchestrated environment where containerized applications can move freely across hardware to evenly distribute load among many devices. While my makefile does not do that yet, it is certainly where I'm going with it eventually. Here is an example of one where I have taken it to kubernetes:

https://github.com/joshuacox/local-ngin ... efile#L167

In any case it is useful for learning docker and/or kubernetes without paying a fortune in AWS fees, and the hardware is really cheap and power efficient to boot.

http://kubernetes.io/

Another point is that the compilation process takes a fair amount of time, and seeing as how I'm on google fiber here, . So in terms of disaster recovery,I can use luxas write script to prep a new SD card, boot the pi, mount NFS, and pull down my 700mb image from docker hub faster than the pi can compile. The neat thing is whether I chose the archlinux or hypriotOS (debian), the debian based domoticz image runs without issue (abstraction of the app from the underlying OS).

Re: Docker on raspberry pi

Posted: Monday 03 October 2016 5:39
by thoth
@remb0 I would be happy to write that for the wiki, where do you think it should go appropriately?

Another advantage I can think of is more integration with other projects. Because, much like myself, I'm sure others are already using their pi for other things. My position at this point is that all pi I run have docker installed, and all of my apps are dockerized so I merely have to copy these git repos around with the necessary info cached into files that are gitignored, and the relevant data directories and start up services. Or have them in NFS etc, and the OS on the sdcard becomes less relevant.

Re: Docker on raspberry pi

Posted: Monday 03 October 2016 10:58
by simonrg
thoth wrote:@remb0 I would be happy to write that for the wiki, where do you think it should go appropriately?

Another advantage I can think of is more integration with other projects. Because, much like myself, I'm sure others are already using their pi for other things. My position at this point is that all pi I run have docker installed, and all of my apps are dockerized so I merely have to copy these git repos around with the necessary info cached into files that are gitignored, and the relevant data directories and start up services. Or have them in NFS etc, and the OS on the sdcard becomes less relevant.
Phew, very neat / sensible.

A Wiki page would be very useful, I currently have a lot of Pis running on a few SD images, but I am not properly managing things.

My thought was to implement NFS / NIS across all the machines, so I just have one set of userids and can easily transfer information between machines.

Then look into Ethernet booting to allow me to keep images on a NAS box.

Adding Docker on top of that would be even more manageable then, I would have one standard Pi image served from NAS to each machine, onto which each machine get implements the appropriate Docker container.

Re: Docker on raspberry pi

Posted: Monday 03 October 2016 15:19
by thoth
I did not realize you could net boot the things as well.

https://www.raspberrypi.org/forums/view ... f=7&t=1444

that makes things very interesting.

Re: Docker on raspberry pi

Posted: Tuesday 04 October 2016 18:29
by thoth
I added a wiki page here:
https://www.domoticz.com/wiki/Docker

and I welcome pull requests and issues here:
https://github.com/joshuacox/mkdomoticz