docker on arm raspberry pi

29
HypriotOS Docker on ARM Boards Eueung Mulyana http://eueung.github.io/docker-stuff/hypriot CodeLabs | Attribution-ShareAlike CC BY-SA 1 / 29

Upload: eueung-mulyana

Post on 13-Apr-2017

551 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Docker on ARM Raspberry Pi

HypriotOS

Docker on ARM BoardsEueung Mulyana

http://eueung.github.io/docker-stuff/hypriotCodeLabs | Attribution-ShareAlike CC BY-SA

1 / 29

Page 2: Docker on ARM Raspberry Pi

Outline

Team Hypriot & HypriotOS

Quick-Start

Let's Get Physical

2 / 29

Page 3: Docker on ARM Raspberry Pi

Team Hypriot & HypriotOS

3 / 29

Page 4: Docker on ARM Raspberry Pi

Team Hypriot - GoalsContainers and the Internet of Things

evangelizing to use Docker container on ARM boardsconvincing Docker containers for IoT applicationsenabling the Docker ecosystem on low-powered devices

Pushing the Docker technology into the IoTworld

"Since we started in early 2015 our mission was to makecontainer technology a �rst class citizen on ARM and IoT devices.Then and now Docker was the dominant container technologyso it made sense to concentrate on Docker"

4 / 29

Ref: Dieter Reuter, Hypriot

Page 5: Docker on ARM Raspberry Pi

Main Featuresminimal Debian-based operating system - most peopleknow how to use Debian & Ubuntu based distrosoptimized for Docker awesomeness - from optimized andtuned Linux kernel settings to the included �leystemseverything is aligned to make Docker run very wellup-to-date Docker versions - often we are only mereseconds behind the o�cially published upstream versionsreally easy to use - download, �ash and boot - that's allyou need to get started

5 / 29

HypriotOSA minimal Debian-based operating systems that is optimized

to run Docker

First Release 02/2014

Ref: About HypriotOS

Page 6: Docker on ARM Raspberry Pi

6 / 29

Concepts - Parts and IdeasThe New HypriotOS

A Debian-based root �lesystem (32 and 64-bit)

A board speci�c layer: Linux kernel, �rmware, bootloader

A common layer: Hypriot speci�c settings and tools, DockerEngine, Compose, Swarm, Machine

An optional application layer e.g. Hypriot Cluster Lab

Page 7: Docker on ARM Raspberry Pi

Complete Docker Toolset on ARM

7 / 29

Page 8: Docker on ARM Raspberry Pi

Quick-Start

8 / 29

Page 9: Docker on ARM Raspberry Pi

Let's Try It ...My Case: amd64 Machine, Ubuntu 16.04

9 / 29

Page 10: Docker on ARM Raspberry Pi

$ sudo apt install pv awscli$ sudo apt install nmap

# awscli might not be necessary

$ wget https://raw.githubusercontent.com/hypriot/flash/master/$(uname $ chmod +x flash$ sudo mv flash /usr/local/bin/flash

$ flash --hostname node2 hypriot-rpi-20160306-192317.img# mmcblk0# or flash http://downloads.hypriot.com/hypriot-rpi-20160306-192317.img.zip

# or using dd# umount ...# sudo dd if=hypriot.img of=/dev/mmcblk0 bs=1M# umount ...

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465,8G 0 disk sda1 8:1 0 449,9G 0 part / sda2 8:2 0 1K 0 part sda5 8:5 0 15,9G 0 part [SWAP]sr0 11:0 1 1024M 0 rom mmcblk0 179:0 0 14,9G 0 disk mmcblk0p1 179:1 0 60M 0 part /media/em/boot mmcblk0p2 179:2 0 14,9G 0 part /media/em/e6e7f776-...

10 / 29

Step #1

Prepare & Flash

Page 11: Docker on ARM Raspberry Pi

$ ping node2.localPING node2.local (192.168.1.100) 56(84) bytes of data.64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=6.44 ms64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=1.96 ms...

$ ssh [email protected] authenticity of host 'node2.local (192.168.1.100)' can't be established.ECDSA key fingerprint is SHA256:tNrdOcXb8tzuEWcC9yJNSP1c51l+7fLJ+QEchAIHA74.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'node2.local,192.168.1.100' (ECDSA) to the list of known [email protected]'s password:

The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.HypriotOS: root@node2 in ~$

# Creds: root/hypriot or pi/raspberry

11 / 29

Step #2

Switch-On & Connect

Page 12: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ hostnamectl Static hostname: node2 Icon name: computer Chassis: n/a Machine ID: f2bcb4a318f14a049f7a3618d9c471c8 Boot ID: 399cf20c996d46c4bf0342aa6bbaa739 Operating System: Raspbian GNU/Linux 8 (jessie) Kernel: Linux 4.1.17-hypriotos-v7+ Architecture: arm

$ cat /etc/os-releasePRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"NAME="Raspbian GNU/Linux"VERSION_ID="8"VERSION="8 (jessie)"ID=raspbianID_LIKE=debianHOME_URL="http://www.raspbian.org/"SUPPORT_URL="http://www.raspbian.org/RaspbianForums"BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

12 / 29

Step #3

Explore - General

Page 13: Docker on ARM Raspberry Pi

$ docker version

Client: Version: 1.10.2 API version: 1.22 Go version: go1.4.3 Git commit: c3959b1 Built: Wed Feb 24 09:51:38 2016 OS/Arch: linux/arm

Server: Version: 1.10.2 API version: 1.22 Go version: go1.4.3 Git commit: c3959b1 Built: Wed Feb 24 09:51:38 2016 OS/Arch: linux/arm

$ docker-compose versiondocker-compose version 1.6.2, build 4d72027docker-py version: 1.7.2CPython version: 2.7.9OpenSSL version: OpenSSL 1.0.1k 8 Jan 2015

$ docker-machine --versiondocker-machine version 0.4.1 (549d016)

13 / 29

Step #4

Explore - Docker Stuff

Page 14: Docker on ARM Raspberry Pi

$ docker info

Containers: 0 Running: 0 Paused: 0 Stopped: 0Images: 2Server Version: 1.10.2Storage Driver: overlay Backing Filesystem: extfsExecution Driver: native-0.2Logging Driver: json-filePlugins: Volume: local Network: bridge null hostKernel Version: 4.1.17-hypriotos-v7+Operating System: Raspbian GNU/Linux 8 (jessie)OSType: linuxArchitecture: armv7lCPUs: 4Total Memory: 925.5 MiBName: node2ID: HX6D:ZAUS:RCVC:OA6Y:NTU6:KJ2P:KUIF:BE6Q:ANIX:U3NE:CMDO:TCHXDebug mode (server): true File Descriptors: 11 Goroutines: 20 System Time: 2016-04-28T12:17:14.540758764+02:00 EventsListeners: 0 Init SHA1: dfeb8c17f8c3a118753fea8353b715a7a75f5491 Init Path: /usr/lib/docker/dockerinit Docker Root Dir: /var/lib/docker

14 / 29

Step #4

Explore - Docker Stuff

Page 15: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ docker pull hypriot/rpi-busybox-httpd

Using default tag: latestlatest: Pulling from hypriot/rpi-busybox-httpdc74a9c6a645f: Pull complete 6f1938f6d8ae: Pull complete e1347d4747a6: Pull complete a3ed95caeb02: Pull complete Digest: sha256:c00342f952d97628bf5dda457d3b409c37df687c859df82b9424f61264f54Status: Downloaded newer image for hypriot/rpi-busybox-httpd:latest

HypriotOS: root@node2 in ~$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhypriot/rpi-swarm latest c298de062190 hypriot/rpi-busybox-httpd latest fbd9685c5ffc

$ docker run -d -p 80:80 hypriot/rpi-busybox-httpdeab926d842ab7b334810517fd5e4574683494d1bb82bcf42dabd8c107e7fbc33HypriotOS: root@node2 in ~

$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESeab926d842ab hypriot/rpi-busybox-httpd "/bin/busybox httpd -"

15 / 29

Step #5

Try - Hypriot World

Page 16: Docker on ARM Raspberry Pi

16 / 29

Page 17: Docker on ARM Raspberry Pi

$ docker build -t jancelin/rpi-monitor git://github.com/jancelin/docker-rpi-monitor

$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEjancelin/rpi-monitor latest 6e70c482c2a2 hypriot/rpi-swarm latest c298de062190 hypriot/rpi-busybox-httpd latest fbd9685c5ffc

$ docker run -p 8888:8888 -p 4200:4200 -d -t jancelin/rpi-monitor

17 / 29

Step #5

Another Try - RPI Monitor

Page 18: Docker on ARM Raspberry Pi

18 / 29

Page 19: Docker on ARM Raspberry Pi

Basic wPi @ Hypriot

Let's Get Physical

19 / 29

Page 20: Docker on ARM Raspberry Pi

$ docker pull hypriot/rpi-gpioUsing default tag: latestlatest: Pulling from hypriot/rpi-gpio

8e7875cfab37: Pull complete 6953557b7832: Pull complete Digest: sha256:4055a39a2b68404c0ac9516b5440d103e52eb711b53e78693a532bd820c5c9c1Status: Downloaded newer image for hypriot/rpi-gpio:latest

HypriotOS: root@node2 in ~$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhypriot/rpi-swarm latest c298de062190 hypriot/rpi-busybox-httpd latest fbd9685c5ffc hypriot/rpi-gpio latest b35a44695fd0

20 / 29

Pull Imagehypriot/rpi-gpio

... the binary from the wiringPi project within a Dockercontainer

Page 21: Docker on ARM Raspberry Pi

21 / 29

Page 22: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ docker run --rm --cap-add SYS_RAWIO --device /dev/mem hypriot/rpi-gpio readall +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3v | | | 1 || 2 | | | 5v | | | | 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5V | | | | 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | | | 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 | | | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 | | 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 | | 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | | | 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 | | | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 | | 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | | | 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 | | 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 | | | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 | | 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 | | 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | | | 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 | | 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | | | 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 | | 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 | | | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

22 / 29

GPIO readall

Page 23: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ docker run --rm --cap-add SYS_RAWIO --device /dev/mem hypriot/rpi-gpio write 0 on

23 / 29

Page 24: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ docker run --rm --cap-add SYS_RAWIO --device /dev/mem hypriot/rpi-gpio write 0 off

24 / 29

Page 25: Docker on ARM Raspberry Pi

25 / 29

Page 26: Docker on ARM Raspberry Pi

HypriotOS: root@node2 in ~$ docker run --rm --cap-add SYS_RAWIO --device /dev/mem hypriot/rpi-gpio read 1

# wPi GPIO 1 / BCM 18# 0 or 1

26 / 29

Page 27: Docker on ARM Raspberry Pi

Refs

27 / 29

Page 28: Docker on ARM Raspberry Pi

Refs1. Docker Pirates ARMed with explosive stu�2. Mastering Docker on a Raspberry Pi3. Let's get physical with Docker on the Raspberry Pi4. WiringPi

28 / 29

Page 29: Docker on ARM Raspberry Pi

ENDEueung Mulyana

http://eueung.github.io/docker-stuff/hypriotCodeLabs | Attribution-ShareAlike CC BY-SA

29 / 29