Docker

From Domoticz
Jump to: navigation, search

Docker

If you are new to Docker itself start with one of their introductions before trying any of the stuff here, for example

Essentially you can just start with `FROM debian:stretch` and follow the wiki

There is a working Dockerfile you can use to start with if you want to build your own

DockerHub

There is an uploaded image for amd64 as well as arm for raspberryPi and the like here

Or you can quickly test it out by pulling:

docker pull joshuacox/mkdomoticz

and running:

 @docker run --name=domoticz \
        --privileged \
        --cidfile="cid" \
        -d \
        -p 8080:8080 \
        -t joshuacox/mkdomoticz

NOTE: --privileged so that domoticz can interact with USB gateways (for example a MySensors nano with NRF24l01 attached), otherwise you have to attach each `/dev` device manually

Persistence

First run an instance like above and grab it’s data dirctory:

        mkdir -p datadir
        docker cp `cat cid`:/config  - |sudo tar -C datadir/ -pxf -

then kill off the first instance and bring it back with a volume mount:

 @docker run --name=domoticz \
        --privileged \
        -d \
        -p 8080:8080 \
        -v `pwd`/datadir/config:/config \
        -t joshuacox/mkdomoticz

ARM

RaspberryPi images with docker

Hypriot has a great getting started page here if you are new to Docker on ARM

For more advanced usage and a headstart on kubernetes use luxas' kubernetes project here while development has slowed on that project because he has become a maintainer for the Docker project, that also means much of his work is going into mainstream docker and ARM should gain official support

For raspberryPi, CHIP, beaglebones, and other ARM based devices you can't use the normal images from dockerhub, you'll need to find ones built for ARM or build it all locally

ARM TAG

On a RaspberryPi use the tag `arm` i.e. `joshuacox/mkdomoticz:arm` the init run now becomes:

 @docker run --name=domoticz \
        --privileged \
        --cidfile="cid" \
        -d \
        -p 8080:8080 \
        -t joshuacox/mkdomoticz:arm

ARM branch

If you clone the Makefile repo you can checkout the arm branch and then make run which will pull the arm image from dockerhub

Makefile

There is a Makefile which automates the above and more such as building locally.

There are branches for raspberryPi as well, checkout the arm branch to pull my image from docker hub, or use the local-stretch to build locally though it should be noted you’lll need a locally built stretch image named local-stretch.

local-debian

There is another Makefile repo for building a copy of local-stretch (and other debians) as well. This is useful for production on any docker setup as you should never trust public images from docker hub and your images should be built from scratch by you. Merely make stretch and a local stretch image can be built using debootstrap (which is available in most distributions [even ones not based on debian]) You can make jessie as well, and it should be trivial to add support for other debian based releases as well. Issues and pull requests are welcome.

local nginx

You may find it useful to route all port 80 and 443 traffic through a single nginx instance. There is yet another Makefile in a repo for that purpose which is based on the above local-stretch.

Forum Discussion

can be found here