Installation of Docker on Raspberry Pi and L Chika

Introduction

It seems that Docker supports Raspberry Pi (Raspbian Jessie). Reference: Git --docker / docker --Add support to install Docker on raspbian / jessie # 24815

I tried L Chika using Docker, so I will summarize the procedure. Reference: Get Started with Docker 1.12 on Raspberry Pi

environment

Raspberry Pi 3 MODEL B Mac (used by default on Raspberry Pi)

procedure

Raspbian installation

First, prepare an image for installation on the SD card. This time, I will use Raspbian Jessie, so download the latest version of the image from here.

Unzip the downloaded Raspbian Jessie zip file.

$ tar zxvf 2016-05-27-raspbian-jessie.zip
x 2016-05-27-raspbian-jessie.img

From here, we will install the image on the SD card. First, check the SD card where you want to install the image.

$ df -ah
Filesystem      Size   Used  Avail Capacity   iused    ifree %iused  Mounted on
/dev/disk1s1    30Gi  2.5Mi   30Gi     1%         0        0  100%   /Volumes/UNTITLED

Format the SD card with FAT32.

$ diskutil eraseDisk FAT32 RPI /dev/disk1
Started erase on disk1
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk1s2 as MS-DOS (FAT32) with name RPI
512 bytes per physical sector
/dev/rdisk1s2: 62501024 sectors in 1953157 FAT32 clusters (16384 bytes/cluster)
bps=512 spc=32 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=411648 drv=0x80 bsec=62531584 bspf=15260 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk1

Unmount the SD card.

$ diskutil unmountDisk /dev/disk1
Unmount of all volumes on disk1 was successful

Write the image you prepared earlier to the SD card.

$ sudo dd bs=1024m if=2016-05-27-raspbian-jessie.img of=/dev/rdisk1
Password:
3+1 records in
3+1 records out
4019191808 bytes transferred in 440.337320 secs (9127529 bytes/sec)

The SD card is now ready!

Raspbian connection and initialization

Insert the SD card you prepared earlier into the Raspberry Pi and turn on the power. After the Raspberry Pi starts, connect with SSH. For the IP address of Raspberry Pi, enter the one confirmed from PING or DHCP log.

$ ssh pi@<IP address of Raspberry Pi>

Set a fixed IP as the initial setting.

pi@raspberrypi:~ $ sudo vi /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.11/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

Docker installation

This is the main subject! Install Docker on your Raspberry Pi.

pi@raspberrypi:~ $ curl -sSL https://get.docker.com/ | sh
+ sudo -E sh -c mkdir -p /etc/systemd/system/docker.service.d
+ sudo -E sh -c echo '[Service]\nExecStart=\nExecStart=/usr/bin/dockerd --storage-driver overlay -H fd://' > /etc/systemd/system/docker.service.d/overlay.conf
+ sudo -E sh -c sleep 3; apt-get update
Get:1 http://archive.raspberrypi.org jessie
(abridgement)
+ sudo -E sh -c docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:31:15 2016
 OS/Arch:      linux/arm

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:31:15 2016
 OS/Arch:      linux/arm

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker pi

Remember that you will have to log out and back in for this to take effect!

Docker has been installed. The version is 1.12.1.

Try starting raspbian: jessie as a trial.

pi@raspberrypi:~ $ sudo docker run -ti resin/rpi-raspbian:jessie /bin/bash
Unable to find image 'resin/rpi-raspbian:jessie' locally
jessie: Pulling from resin/rpi-raspbian
2c21a521f21e: Pull complete 
d99cff50dc11: Pull complete 
c1c51ee47f0b: Pull complete 
e8b3c50e8e7e: Pull complete 
a3ed95caeb02: Pull complete 
7f56c2fb9a9c: Pull complete 
75010306b0df: Pull complete 
8837443d430d: Pull complete 
23dd9b04a2ec: Pull complete 
Digest: sha256:b6aef386a6da25bfbcba0e14a748e5473ff798233155fad960ae08fa4c94b146
Status: Downloaded newer image for resin/rpi-raspbian:jessie
root@f94112ff9ddc:/# 

It has started!

L Chika from Docker container

Since it is a Raspberry Pi, I will try L-Chika from the container.

hardware

Connect the Raspberry Pi and the LED. I connected the LED to the Raspberry Pi as shown in the circuit diagram.

Screen-Shot-2016-08-20-at-09-40-46-1.png Quote: [Get Started with Docker 1.12 on Raspberry Pi](http://blog.alexellis.io/getting-started-with-docker-on-raspberry-pi/)

software

Prepare the container and program. First of all, regarding containers, L-Chika accesses / dev / mem, so I think there are two ways to start a container.

Start the container with the * privileged option → Describe here

You don't need to restrict access to the device, so start the container with the privileged option.

pi@raspberrypi:~ $ sudo docker run -ti --privileged resin/rpi-raspbian:jessie /bin/bash
root@3bfcfa574e1e:/# 

This time, I will use rpi.gpio of python for L-Chika. Install the required packages and libraries.

root@3bfcfa574e1e:/# apt-get update
root@3bfcfa574e1e:/# apt-get install python python-pip python-dev gcc make vim
root@3bfcfa574e1e:/# pip install rpi.gpio

Create a program that blinks the LED.

chikachika.py


import RPi.GPIO as GPIO  
import time  
GPIO.setmode(GPIO.BCM)  
led_pin = 17  
GPIO.setup(led_pin, GPIO.OUT)

while(True):  
    GPIO.output(led_pin, GPIO.HIGH)
    time.sleep(1)
    GPIO.output(led_pin, GPIO.LOW)
    time.sleep(1)

Flickering

Run the program.

root@3bfcfa574e1e:/# python chikachika.py

It was flickering.

in conclusion

With Docker, you can quickly prepare a beautiful environment, so I felt that it would have a high affinity with Raspberry Pi.

Recommended Posts

Installation of Docker on Raspberry Pi and L Chika
L Chika on Raspberry Pi C #
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Try L Chika with raspberry pi
pigpio on Raspberry pi
Cython on Raspberry Pi
Record temperature and humidity with systemd on Raspberry Pi
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Implementation of personally optimized photo frames on Raspberry Pi
Control power on / off of USB port of Raspberry Pi
Install pyenv on Raspberry Pi and version control Python
Troubleshoot with installing OpenCV on Raspberry Pi and capturing
Memo of migrating Django's DB from SQLite 3 to MySQL on Docker on Raspberry Pi 4B
Create your own IoT platform using raspberry pi and ESP32 (Part 2) ~ ESP32 setting L Chika
Introduced pyenv on Raspberry Pi
Source installation and installation of Python
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
Production of temperature control system with Raspberry Pi and ESP32 (1)
Testing uart communication on Raspberry Pi
Installation of SciPy and matplotlib (Python)
Easy installation of OpenCV on RaspberryPi 3+
Install ghoto2 on Raspberry Pi (memo)
Completion of docker command on Linux
Try using ArUco on Raspberry Pi
Weighing instrument using raspberry pi and hx711 (GUI display on Tkinter)
Graph display of household power consumption with 3GPI and Raspberry Pi
Installation and easy usage of pytest
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Initial settings for using GrovePi + starter kit and camera on Raspberry Pi
Production of temperature control system with Raspberry Pi and ESP32 (2) Production of transmission device
Installation of Visual studio code and installation of python
Pet monitoring with Rekognition and Raspberry pi
"Honwaka Notification Lamp" on Raspberry Pi Part 2
[Raspberry Pi] Add a thermometer and a hygrometer
Detect "brightness" using python on Raspberry Pi 3!
docker and PyCharm under proxy on windows
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Link WAS and FLASK applications on docker
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Set swap space on Ubuntu on Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Install 64-bit OS (bate) on Raspberry Pi
Installation of psutil fails on MacOS Cataline
Install docker-compose on 64-bit Raspberry Pi OS
Run servomotor on Raspberry Pi 3 using python
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +
Comparison of L1 regularization and Leaky Relu
Detect temperature using python on Raspberry Pi 3!
Mount Windows shared folder on Raspberry Pi