Rpi Docker Install

broken image


It is possible to run Zigbee2MQTT in a Docker container using the official Zigbee2MQTT Docker image.

This image support the following architectures: 386, amd64, arm/v6, arm/v7, arm64.Since Zigbee2MQTT images are manifest listed, Docker will auto-detect the architecture and pull the right image.

Note for Raspberry Pi 1 and zero users: there is a bug in Docker which selects the wrong image architecture.Before executing docker run pull the correct image with docker pull koenkk/zigbee2mqtt --platform linux/arm/v6.

First run the container, this will create the configuration directory. Change configuration.yaml according to your situation and start again.

Millions of real salary data collected from government and companies - annual starting salaries, average salaries, payscale by company, job title, and city. UPDATE 12/5/2020 – If you are looking for installation instructions or USB booting instructions for Ubuntu 20.04 / 20.10 check out my new updated guide here. This is a unofficial distribution of Ubuntu Server 18.04.4 for Raspberry Pi 4.

Running #

Run by executing the following commmand:

The Ubuntu Server image is much smaller, you can install flavours of the Ubuntu Desktop on top of it, it gives you access to the Ubuntu CLI and by extension, all of the latest open source. Ubuntu Server works on the Raspberry Pi 2, 3 and 4. Getting started with Home Assistant. Help us to improve our documentation Suggest an edit to this page, or provide/view feedback for this page. Build a single or multi-room streamer for an existing audio device using a Raspberry Pi! Supports Bluetooth, Airplay and Spotify Connect - balenalabs/balena-sound.

Parameters explanation #

  • -v $(pwd)/data:/app/data: Directory where Zigbee2MQTT stores it configuration
  • --device=/dev/ttyACM0: Location of adapter (e.g. CC2531)
  • -v /run/udev:/run/udev:ro --privileged=true: is optional, only required for autodetecting the port
  • Optional: in case your MQTT broker is running on localhost and is not within the same Docker network as the Zigbee2MQTT container also add --network host .

Updating #

To update to the latest Docker image:

Tags #

The following tags are available:

  • Latest release version: latest
  • Latest dev version (based on dev branch): latest-dev
  • Specific release version, e.g: 1.7.0

Support new devices #

See How to support new devices

docker-compose example #

Docker Stack device mapping #

This is only relevant when using Docker Stack

Docker stack doesn't support device mappings with option --devices when deploying a stack in Swam mode. A workaround is to bind the device as volume binding and set the right permissions.

The workaround is based on the solution found at Add support for devices with 'service create', all credits goes this him.

  1. Identify cc2531 device Identify the cc2531 device using the following command:

  2. UDEV Rules

    Create a new udev rule for cc2531, idVendor and idProduct must be equal to values from lsusb command. The rule below creates device /dev/cc2531:

    Reload newly created rule using the following command:

  3. Create docker-setup-cc2531.sh

    Copy the following content:

    Set permissions:

  4. Create docker-event-listener.sh

    Copy the following content:

    Set permissions:

  5. Create docker-event-listener.service

    Copy the following content:

    Set permissions:

    Reload daemon

    Start Docker event listener

    Status Docker event listener

    Enable Docker event listener

  6. Verify and deploy Zigbee2MQTT stack

    Now reconnect the cc2531. Verify using the following command:

    Below an example of a docker-stack-zigbee2mqtt.yml:

    In the above example, proxy_traefik-net is the network to connect to the mqtt broker. The constraint makes sure Docker deploys only to this (rpi-3) node, where the cc2531 is connected to. The volume binding /mnt/docker-cluster/zigbee2mqtt/data is the zigbee2mqtt persistent directory, where configuration.yaml is saved.

    The zigbee2Zigbee2MQTTmqtt configuration.yaml should point to /dev/cc2531:

    Deploy the stack:

Here are 5 things you need to know about using Docker on the Raspberry Pi from Docker Captain Alex Ellis@alexellisuk

If you're new to Docker then visit my Hands-On Docker online workshop: Hands-On Docker labs

1. Install Docker with one command

Today there is no need to brace yourself for pages of hacks or technical jargon to get Docker onto your device. One command does it all (through apt-get behind the scenes) - you can even memorise the command:

On Raspbian enter:

Providing you're running Debian or a derivative you're now good to go. The folks at the Docker project build docker/docker from source through CI which includes quality gates around unit and integration tests.

2. Know your Architecture

The Raspberry Pi hardware architecture is called ARM and differs from the architecture behind your regular PC, laptop or cloud instance.

What does that mean? A binary built for either system will not execute on the other.

The helloworld container will not work on the RPi. I'd suggest starting with my tutorial Get started with Docker on your RPi. It recommends a good set of base images to build what you need - whether that be Go, Node.js, Python, Nginx or something completely different.

The following shortcut will show you the architecture on a Pi or regular Linux machine:

Output from my Raspberry Pi and an Azure cloud instance of Ubuntu

All Pis are compatible with ARMv6 architecture so for simplicity's sake I recommend you build your code through an ARMv6 base image and only pull in official distribution binaries from the likes of Golang, Nodejs, InfluxDB etc where they target that architecture.

Raspberry

What does this mean? It means you can't docker run -d -p 80:80 nginx:latest - read on for the workaround.

3. You can't trust anyone (yet)

This may seem like a harsh thing to say - but in a climate where even baby monitors and lightbulbs can be taken over to participate in DDOS attacks we need to get smart.

  • Don't use an image unless it's official

There are no truly official images but resin/rpi-raspbian is used by thousands of devices and curated by resin.io. I would recommend creating all your images from this as a base.

The Docker team are working on a set of semi-official images under the namespace armhf and you will see those images coming into play in the Dockerfile.armhf in the docker/docker repo.

Anil from the Docker Inc. team in Cambridge told me how his team are procuring ARM servers like they were going out of fashion in order to create a build-farm to support ARM devices. That infrastructure will enable autobuild support on the public Docker Hub.

  • Don't run any binaries you that didn't compile yourself

10.6 download. Even if it takes 2 days to compile PhantomJS - it's still way better than relying on a tar.gz provided by someone you know nothing about on the internet.

Docker Security by Adrian Mouat coins the term poison image for an image tainted with malware.

I have provided a set of Dockerfiles on Github for common software such as Node.js, Python, Consul and Nginx:

Github: alexellis/docker-arm

If you want to create a Docker image for software such as Prometheus.io, Node.js or Golang then head over to their download page and locate the official binary package for ARM - then add it into one of the base images we covered above.

If no binary exists then take the time to re-build from source and don't take any risks. Google the build instructions if you run into issues - they can often be found from a 5-minute search.

4. Get physical

The Raspberry Pi excels at interfacing with hardware through it's 40-pin header. You can talk to just about any electrical component directly or through add-on boards - if it's rated for 3.3v/5v that's a good start. Manufacturers like Pimoroni have a wealth of purpose-built sensor and LED boards which mean no trailing wires or complicated code libraries.

Have you seen my IoT demo from Dockercon and Container.Camp yet?

Pre-recorded demo for Dockercon break glass in case of laptop failure.

All the Dockerfiles, Python code and build instructions are publicly available. I couldn't have done any of this without the Pi's support for physical hardware.

  • Container Camp write-up including my IoT demo.

Getting live demonstrations from @alexellisuk at @AgilePBoro@docker#ctmtechpic.twitter.com/6o1Ju0u5lm

— comparethemarkt_tech (@comparemkttech) September 21, 2016

5. Build a super-computer

Building a cluster has never been easier than with the built-in Swarm Mode from Docker 1.12 onwards. Take it from me because I spent weeks rebuilding the Swarm, Consul binaries etc to set up a 28-CPU swarm for Linux User magazine.

Now I type in one command on my manager and another on the workers. What's more the managers can also do useful work, where as in the original swarm mode that was harder to achieve.

See Docker's presentation from Container.Camp right here - it literally takes two commands to begin building a super-computer.

Want a secure @docker cluster? No problem, it's built-in: two commands and you're set. @containercamppic.twitter.com/viZ3CEy47g

— Alex Ellis (@alexellisuk) September 9, 2016

The second most common question I get asked is: can I run a minecraft-super-server with a Pi cluster? The short answer is no and the long answer is yes.

You probably won't be playing a graphics-intensive game at a better FPS rate over your new Pi cluster and it probably won't make loading Chrome any quicker, but it's an invaluable learning tool.

You can can deploy your distributed application at an infrastructure rather than at a specific set of servers. For instance:

  • Deploy an application on real hardware
  • Simulate network/power failures
  • Code against the Docker remote API
  • Track down bottle-necks and show scaling different services increases throughput (or not)

Raspberry Pi Pihole Docker Install

Where next?

Connect with me on Twitter @alexellisuk to go deeper with Docker, DevOps and containers.

Install Docker For Rpi

There's over 28 Raspberry Pi and Docker tutorials on my blog. Explore them all here - ranging from time lapses to IoT sensor monitoring to learning Golang:

Rpi Install Docker Compose

Want to learn the basics of Docker in a hands-on way? Visit or fork my online workshop: Hands-On Docker labs





broken image