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
Raspberry Pi 3 MODEL B Mac (used by default on Raspberry Pi)
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!
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
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!
Since it is a Raspberry Pi, I will try L-Chika from the container.
Connect the Raspberry Pi and the LED. I connected the LED to the Raspberry Pi as shown in the circuit diagram.
Quote: [Get Started with Docker 1.12 on Raspberry Pi](http://blog.alexellis.io/getting-started-with-docker-on-raspberry-pi/)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)
Run the program.
root@3bfcfa574e1e:/# python chikachika.py
It was flickering.
With Docker, you can quickly prepare a beautiful environment, so I felt that it would have a high affinity with Raspberry Pi.
Recommended Posts