SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
Docker for the Internet of Things
(IoT): An Introduction
Mohd Syukor Abdul
14 March 2019
1
Agenda
2
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
Agenda
3
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
What is Internet of Things
“IoT is a world of interconnected things which are capable of
sensing, actuating and communicating among themselves
and with the environment (i.e., smart things or smart
objects) while providing the ability to share information and
act in parts autonomously to real/physical world events and
by triggering processes and creating services with or
without direct human intervention.”
Source: Qusay F. Hassan (ed.)(2018), Internet of Things A to Z:
Technologies and Applications. Wiley-IEEE Press.
4
What is Docker?
• Docker is a platform for developing, shipping and running
applications using container virtualization from development to
production both on premises and in the cloud.
• Docker containers wrap up a piece of software in a complete file
system that contains everything it needs to run: code, runtime,
system tools, system libraries – anything you can install on a server.
• This guarantees that it will always run the same, regardless of the
environment it is running in.
5
https://www.docker.com/
Why use Docker for IoT?
6
Docker created the industry
standard for containers, so
they could be portable
anywhere.
Docker provides a consistent
environment for application
from the development all
the way to production.
Applications are safer in
containers and Docker
provides the strongest
default isolation capabilities
in the industry.
Containers share the
machine’s OS system kernel
and therefore do not require
an OS per application,
driving higher efficiencies
and density.
Agenda
7
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
What is Raspberry Pi?
The Raspberry Pi is a low cost, credit-card sized computer that plugs into
a computer monitor or TV, and uses a standard keyboard and mouse.
It is a capable little device that enables people of all ages to explore
computing, and to learn how to program in languages like Scratch and
Python.
It’s capable of doing everything you’d expect a desktop computer to do,
from browsing the internet and playing high-definition video, to making
spreadsheets, word-processing, and playing games.
What’s more, the Raspberry Pi has the ability to interact with the outside
world, and has been used in a wide array of digital maker projects, from
music machines and parent detectors to weather stations and tweeting
birdhouses with infra-red cameras.
8
https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/
Raspberry Pi Family Photo
9https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
Raspberry Pi Family Photo
10
https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
Raspberry Pi Zero W
11
Raspberry Pi Zero W Specs
Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8)
64-bit SoC @ 1.4GHz
Memory 512MB LPDDR2 SDRAM
Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac
wireless LAN
Bluetooth Bluetooth 4.2/BLE
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5 mm analogue audio-video jack,
1x USB 2.0, Camera Serial Interface (CSI),
Display Serial Interface (DSI)
Dimensions 67×56×11.5 mm
Raspberry Pi 3 B+
12
Raspberry Pi 3 B+ Specs
Processor Broadcom BCM2837B0 quad-core A53
(ARMv8) 64-bit @ 1.4GHz
Memory 1GB LPDDR2 SDRAM
Networking Gigabit Ethernet (via USB channel), 2.4GHz
and 5GHz 802.11b/g/n/ac Wi-Fi
Bluetooth Bluetooth 4.2, Bluetooth Low Energy (BLE)
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5mm analogue audio-video jack, 4x
USB 2.0, Ethernet, Camera Serial Interface
(CSI), Display Serial Interface (DSI)
Dimensions 82mm x 56mm x 19.5mm
Raspberry Pi 3 A+
13
Raspberry Pi 3 A+ Specs
Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8)
64-bit SoC @ 1.4GHz
Memory 512MB LPDDR2 SDRAM
Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac
wireless LAN
Bluetooth Bluetooth 4.2/BLE
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5 mm analogue audio-video jack,
1x USB 2.0, Camera Serial Interface (CSI),
Display Serial Interface (DSI)
Dimensions 67×56×11.5 mm
Agenda
14
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
Docker: Introduction
15
Docker Image
The basis of a Docker container. Represents a full application.
Docker Container
The standard unit in which the application service resides and executes.
Registry Service (Docker Hub or Docker Trusted Registry)
Cloud or server based storage and distribution service for your images.
Docker Engine
Creates, ships and runs Docker containers deployable on a physical
or virtual, host locally, in a datacenter or cloud service provider.
Docker Volume
The storage for persisting data generated by and used by Docker containers.
Docker: Image and Container
16
Image
Container
(Running)
Container
(Stop)
Container
(Deleted)
Image
(Deleted)
Container
(Restart)
Docker Host
Docker Registry
Docker Registry
Docker: Docker Hub
17
Docker Hub is the world’s largest repository of container images
with an array of content sources including container community
developers, open source projects and independent software
vendors (ISV) building and distributing their code in containers.
Users get access to free public repositories for storing and sharing
images or can choose subscription plan for private repos.
https://hub.docker.com/
Docker: Commands
18
docker image ls
docker container ls
docker ps
docker ps -a
docker inspect <container-id>
docker start <container-id>
docker stop <container-id>
docker rm <container-id>
docker rmi <image-id>
docker pull <registry/imagename:tag>
docker logs <container-id>
https://docs.docker.com/engine/reference/commandline/docker/
+ more …
Agenda
19
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
Docker: Setup for RPi
Requirements:
a. Raspberry Pi 3 B+
b. High speed MicroSD card
c. Raspbian OS image (https://www.raspberrypi.org/downloads)
d. USB Memory Card Writer
e. Image Flasher Balena Etcher (https://www.balena.io/etcher/)
f. Laptop with MicroUSB cable
g. Terminal Software Putty
(https://www.chiark.greenend.org.uk/~sgtatham/putty/)
h. Good internet connection
20
Docker: Installation in the RPi
Steps:
1) Flash Raspbian image using Balena Etcher into MicroSD
2) Put MicroSD into RPi MicroSD slot
3) Boot Raspberry Pi
4) Configure internet connection (Wired/WiFi)
5) Update & Upgrade Raspbian OS
6) Install Docker Community Edition (CE)
7) Pull Docker Image
8) Run Docker Container
21
Docker: Installation in the RPi
In the terminal:
sudo apt clean all
sudo apt update
sudo apt upgrade –y
sudo apt dist-upgrade –y
sudo reboot
22
Docker: Installation in the RPi
In the terminal:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod –aG docker pi
sudo reboot
23
https://docs.docker.com/install/linux/docker-ce/debian/#install-using-the-convenience-script
Verifying Docker Installation
In the terminal:
docker version
docker info
24
Raspberry Pi OS and CPU Model
In the terminal:
cat /etc/os-release
cat /proc/cpuinfo | grep model
25
Docker: Hello World
In the terminal:
docker run armhf/hello-world
docker run -d -p 8080:80 arm32v7/nginx
curl http://localhost:8080
26
Docker: Playing with Docker
docker search ...
docker pull ...
docker images ...
docker run ...
docker ps ...
docker inspect ...
docker logs ...
docker stop ...
docker start ...
docker rm ...
docker rmi ...
27
Refer: https://docs.docker.com/engine/reference/commandline/docker/
Agenda
28
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
MQTT Broker
URL: https://hub.docker.com/_/eclipse-mosquitto
docker run -it -p 1883:1883 -p 9001:9001 eclipse-
mosquitto
29
MQTT Client
Linux, Windows & MacOS:
MQTT.fx (https://mqttfx.jensd.de/)
MQTT Spy (https://github.com/eclipse/paho.mqtt-spy/wiki)
MQTTBox (http://workswithweb.com/html/mqttbox/downloads.html)
Android: Search MQTT
MyMQTT, MQTT Client, MQTT Buddy
IOS: Search MQTT
MQTTool, MQTT Buddy, MQTT Terminal
30
Agenda
31
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
Python
URL: https://hub.docker.com/_/python
docker pull arm32v7/python
docker run -it --name mypython1 arm32v7/python
URL: https://hub.docker.com/r/resin/raspberry-pi-python
docker pull balenalib/armv7hf-alpine-python
docker run -it --name mypython1 balenalib/armv7hf-
alpine-python
32
Agenda
33
Introduction
1
Raspberry Pi
2
Docker: Introduction
3
Docker: Setup for RPi
4
Docker: MQTT
5
Docker: Python
6
Docker: Python GPIO Zero
7
Python GPIO Zero
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
34
blinky.py
 https://www.raspberrypi.org/blog/gpio-zero-a-friendly-python-api-for-physical-computing/
 https://gpiozero.readthedocs.io/en/stable/
Python GPIO Zero – In Container Command Lines
35
docker run -it --privileged arm32v7/python bash
apt update
apt install nano
nano blinky.py
python blinky.py
Edit file blinky.py
Run blinky.py
Install text editor
Python GPIO Zero Using Dockerfile
36
FROM arm32v7/python
COPY blinky.py ./
RUN pip install --no-cache-dir gpiozero
CMD ["python", "./blinky.py"]
Dockerfile
cd ~
mkdir python-blinky
cd python-blinky
nano blinky.py
nano Dockerfile
docker build -t myblinky .
docker run --privileged myblinky
Thank You
37
https://www.slideshare.net/msyukor/presentations

Weitere ähnliche Inhalte

Was ist angesagt?

Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to Production
Patrick Chanezon
 
Docker Devoxx UK - Never mind the bollocks here's the Linux Containers
Docker Devoxx UK - Never mind the bollocks here's the Linux ContainersDocker Devoxx UK - Never mind the bollocks here's the Linux Containers
Docker Devoxx UK - Never mind the bollocks here's the Linux Containers
Patrick Chanezon
 

Was ist angesagt? (20)

Docker-Hanoi @DKT , Presentation about Docker Ecosystem
Docker-Hanoi @DKT , Presentation about Docker EcosystemDocker-Hanoi @DKT , Presentation about Docker Ecosystem
Docker-Hanoi @DKT , Presentation about Docker Ecosystem
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016
 
Rooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in DockerRooting Out Root: User namespaces in Docker
Rooting Out Root: User namespaces in Docker
 
Docker Platform and Ecosystem
Docker Platform and EcosystemDocker Platform and Ecosystem
Docker Platform and Ecosystem
 
Docker : Container Virtualization
Docker : Container VirtualizationDocker : Container Virtualization
Docker : Container Virtualization
 
Usernetes: Kubernetes as a non-root user
Usernetes: Kubernetes as a non-root userUsernetes: Kubernetes as a non-root user
Usernetes: Kubernetes as a non-root user
 
[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode[DockerCon 2019] Hardening Docker daemon with Rootless mode
[DockerCon 2019] Hardening Docker daemon with Rootless mode
 
Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to Production
 
Couchbase on Docker - Couchbase Connect 2015
Couchbase on Docker - Couchbase Connect 2015Couchbase on Docker - Couchbase Connect 2015
Couchbase on Docker - Couchbase Connect 2015
 
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker Security
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Rishidot research briefing notes Cloudscaling
Rishidot research briefing notes   CloudscalingRishidot research briefing notes   Cloudscaling
Rishidot research briefing notes Cloudscaling
 
Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
 
Docker Devoxx UK - Never mind the bollocks here's the Linux Containers
Docker Devoxx UK - Never mind the bollocks here's the Linux ContainersDocker Devoxx UK - Never mind the bollocks here's the Linux Containers
Docker Devoxx UK - Never mind the bollocks here's the Linux Containers
 
Continous delivery at docker age
Continous delivery at docker ageContinous delivery at docker age
Continous delivery at docker age
 

Ähnlich wie Docker for the Internet of Things (IoT): An Introduction

Ähnlich wie Docker for the Internet of Things (IoT): An Introduction (20)

Resinio
ResinioResinio
Resinio
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Mastering Docker on a Raspberry Pi
Mastering Docker on a Raspberry PiMastering Docker on a Raspberry Pi
Mastering Docker on a Raspberry Pi
 
Raspberry Pi introduction
Raspberry Pi introductionRaspberry Pi introduction
Raspberry Pi introduction
 
容器與IoT端點應用
容器與IoT端點應用容器與IoT端點應用
容器與IoT端點應用
 
Neo4J with Docker and Azure - GraphConnect 2015
Neo4J with Docker and Azure - GraphConnect 2015Neo4J with Docker and Azure - GraphConnect 2015
Neo4J with Docker and Azure - GraphConnect 2015
 
IAU workshop 2018 day one
IAU workshop 2018 day oneIAU workshop 2018 day one
IAU workshop 2018 day one
 
Micropython for the iot
Micropython for the iotMicropython for the iot
Micropython for the iot
 
Moby Open Source Summit North America 2017
Moby Open Source Summit North America 2017Moby Open Source Summit North America 2017
Moby Open Source Summit North America 2017
 
Docker opens the Doors for IoT
Docker opens the Doors for IoTDocker opens the Doors for IoT
Docker opens the Doors for IoT
 
Raspberry Pi - Unlocking New Ideas for Your Library
Raspberry Pi - Unlocking New Ideas for Your LibraryRaspberry Pi - Unlocking New Ideas for Your Library
Raspberry Pi - Unlocking New Ideas for Your Library
 
Containers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech TalkContainers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech Talk
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PI
 
DockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General SessionDockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General Session
 
Building a Raspberry Pi Robot with Dot NET 7, Blazor and SignalR - TechDays 2023
Building a Raspberry Pi Robot with Dot NET 7, Blazor and SignalR - TechDays 2023Building a Raspberry Pi Robot with Dot NET 7, Blazor and SignalR - TechDays 2023
Building a Raspberry Pi Robot with Dot NET 7, Blazor and SignalR - TechDays 2023
 
Eclipse Kura Shoot a-pi
Eclipse Kura Shoot a-piEclipse Kura Shoot a-pi
Eclipse Kura Shoot a-pi
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
introduction to Raspberry pi
introduction to Raspberry pi introduction to Raspberry pi
introduction to Raspberry pi
 
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ....docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Docker for the Internet of Things (IoT): An Introduction

  • 1. Docker for the Internet of Things (IoT): An Introduction Mohd Syukor Abdul 14 March 2019 1
  • 2. Agenda 2 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 3. Agenda 3 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 4. What is Internet of Things “IoT is a world of interconnected things which are capable of sensing, actuating and communicating among themselves and with the environment (i.e., smart things or smart objects) while providing the ability to share information and act in parts autonomously to real/physical world events and by triggering processes and creating services with or without direct human intervention.” Source: Qusay F. Hassan (ed.)(2018), Internet of Things A to Z: Technologies and Applications. Wiley-IEEE Press. 4
  • 5. What is Docker? • Docker is a platform for developing, shipping and running applications using container virtualization from development to production both on premises and in the cloud. • Docker containers wrap up a piece of software in a complete file system that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. • This guarantees that it will always run the same, regardless of the environment it is running in. 5 https://www.docker.com/
  • 6. Why use Docker for IoT? 6 Docker created the industry standard for containers, so they could be portable anywhere. Docker provides a consistent environment for application from the development all the way to production. Applications are safer in containers and Docker provides the strongest default isolation capabilities in the industry. Containers share the machine’s OS system kernel and therefore do not require an OS per application, driving higher efficiencies and density.
  • 7. Agenda 7 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 8. What is Raspberry Pi? The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games. What’s more, the Raspberry Pi has the ability to interact with the outside world, and has been used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras. 8 https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/
  • 9. Raspberry Pi Family Photo 9https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
  • 10. Raspberry Pi Family Photo 10 https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
  • 11. Raspberry Pi Zero W 11 Raspberry Pi Zero W Specs Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz Memory 512MB LPDDR2 SDRAM Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN Bluetooth Bluetooth 4.2/BLE General Purpose Input/Output (GPIO) Extended 40-pin GPIO header Storage Micro SD Ports HDMI, 3.5 mm analogue audio-video jack, 1x USB 2.0, Camera Serial Interface (CSI), Display Serial Interface (DSI) Dimensions 67×56×11.5 mm
  • 12. Raspberry Pi 3 B+ 12 Raspberry Pi 3 B+ Specs Processor Broadcom BCM2837B0 quad-core A53 (ARMv8) 64-bit @ 1.4GHz Memory 1GB LPDDR2 SDRAM Networking Gigabit Ethernet (via USB channel), 2.4GHz and 5GHz 802.11b/g/n/ac Wi-Fi Bluetooth Bluetooth 4.2, Bluetooth Low Energy (BLE) General Purpose Input/Output (GPIO) Extended 40-pin GPIO header Storage Micro SD Ports HDMI, 3.5mm analogue audio-video jack, 4x USB 2.0, Ethernet, Camera Serial Interface (CSI), Display Serial Interface (DSI) Dimensions 82mm x 56mm x 19.5mm
  • 13. Raspberry Pi 3 A+ 13 Raspberry Pi 3 A+ Specs Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz Memory 512MB LPDDR2 SDRAM Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN Bluetooth Bluetooth 4.2/BLE General Purpose Input/Output (GPIO) Extended 40-pin GPIO header Storage Micro SD Ports HDMI, 3.5 mm analogue audio-video jack, 1x USB 2.0, Camera Serial Interface (CSI), Display Serial Interface (DSI) Dimensions 67×56×11.5 mm
  • 14. Agenda 14 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 15. Docker: Introduction 15 Docker Image The basis of a Docker container. Represents a full application. Docker Container The standard unit in which the application service resides and executes. Registry Service (Docker Hub or Docker Trusted Registry) Cloud or server based storage and distribution service for your images. Docker Engine Creates, ships and runs Docker containers deployable on a physical or virtual, host locally, in a datacenter or cloud service provider. Docker Volume The storage for persisting data generated by and used by Docker containers.
  • 16. Docker: Image and Container 16 Image Container (Running) Container (Stop) Container (Deleted) Image (Deleted) Container (Restart) Docker Host Docker Registry Docker Registry
  • 17. Docker: Docker Hub 17 Docker Hub is the world’s largest repository of container images with an array of content sources including container community developers, open source projects and independent software vendors (ISV) building and distributing their code in containers. Users get access to free public repositories for storing and sharing images or can choose subscription plan for private repos. https://hub.docker.com/
  • 18. Docker: Commands 18 docker image ls docker container ls docker ps docker ps -a docker inspect <container-id> docker start <container-id> docker stop <container-id> docker rm <container-id> docker rmi <image-id> docker pull <registry/imagename:tag> docker logs <container-id> https://docs.docker.com/engine/reference/commandline/docker/ + more …
  • 19. Agenda 19 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 20. Docker: Setup for RPi Requirements: a. Raspberry Pi 3 B+ b. High speed MicroSD card c. Raspbian OS image (https://www.raspberrypi.org/downloads) d. USB Memory Card Writer e. Image Flasher Balena Etcher (https://www.balena.io/etcher/) f. Laptop with MicroUSB cable g. Terminal Software Putty (https://www.chiark.greenend.org.uk/~sgtatham/putty/) h. Good internet connection 20
  • 21. Docker: Installation in the RPi Steps: 1) Flash Raspbian image using Balena Etcher into MicroSD 2) Put MicroSD into RPi MicroSD slot 3) Boot Raspberry Pi 4) Configure internet connection (Wired/WiFi) 5) Update & Upgrade Raspbian OS 6) Install Docker Community Edition (CE) 7) Pull Docker Image 8) Run Docker Container 21
  • 22. Docker: Installation in the RPi In the terminal: sudo apt clean all sudo apt update sudo apt upgrade –y sudo apt dist-upgrade –y sudo reboot 22
  • 23. Docker: Installation in the RPi In the terminal: curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod –aG docker pi sudo reboot 23 https://docs.docker.com/install/linux/docker-ce/debian/#install-using-the-convenience-script
  • 24. Verifying Docker Installation In the terminal: docker version docker info 24
  • 25. Raspberry Pi OS and CPU Model In the terminal: cat /etc/os-release cat /proc/cpuinfo | grep model 25
  • 26. Docker: Hello World In the terminal: docker run armhf/hello-world docker run -d -p 8080:80 arm32v7/nginx curl http://localhost:8080 26
  • 27. Docker: Playing with Docker docker search ... docker pull ... docker images ... docker run ... docker ps ... docker inspect ... docker logs ... docker stop ... docker start ... docker rm ... docker rmi ... 27 Refer: https://docs.docker.com/engine/reference/commandline/docker/
  • 28. Agenda 28 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 29. MQTT Broker URL: https://hub.docker.com/_/eclipse-mosquitto docker run -it -p 1883:1883 -p 9001:9001 eclipse- mosquitto 29
  • 30. MQTT Client Linux, Windows & MacOS: MQTT.fx (https://mqttfx.jensd.de/) MQTT Spy (https://github.com/eclipse/paho.mqtt-spy/wiki) MQTTBox (http://workswithweb.com/html/mqttbox/downloads.html) Android: Search MQTT MyMQTT, MQTT Client, MQTT Buddy IOS: Search MQTT MQTTool, MQTT Buddy, MQTT Terminal 30
  • 31. Agenda 31 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 32. Python URL: https://hub.docker.com/_/python docker pull arm32v7/python docker run -it --name mypython1 arm32v7/python URL: https://hub.docker.com/r/resin/raspberry-pi-python docker pull balenalib/armv7hf-alpine-python docker run -it --name mypython1 balenalib/armv7hf- alpine-python 32
  • 33. Agenda 33 Introduction 1 Raspberry Pi 2 Docker: Introduction 3 Docker: Setup for RPi 4 Docker: MQTT 5 Docker: Python 6 Docker: Python GPIO Zero 7
  • 34. Python GPIO Zero from gpiozero import LED from time import sleep led = LED(17) while True: led.on() sleep(1) led.off() sleep(1) 34 blinky.py  https://www.raspberrypi.org/blog/gpio-zero-a-friendly-python-api-for-physical-computing/  https://gpiozero.readthedocs.io/en/stable/
  • 35. Python GPIO Zero – In Container Command Lines 35 docker run -it --privileged arm32v7/python bash apt update apt install nano nano blinky.py python blinky.py Edit file blinky.py Run blinky.py Install text editor
  • 36. Python GPIO Zero Using Dockerfile 36 FROM arm32v7/python COPY blinky.py ./ RUN pip install --no-cache-dir gpiozero CMD ["python", "./blinky.py"] Dockerfile cd ~ mkdir python-blinky cd python-blinky nano blinky.py nano Dockerfile docker build -t myblinky . docker run --privileged myblinky