LoginSignup
2
1

More than 3 years have passed since last update.

第01回 Raspberry Piのセットアップ、Docker環境のセットアップ

Last updated at Posted at 2019-05-31

はじめに

本文書を参照頂きありがとうございます。
この文書は社内勉強会に向けた文書である為、一部期待値と異なる表現、記載がある場合がありますので、ご利用になられる際はその辺りも加味して頂いてご利用下さい。

Raspberry Piのセットアップに必要なもの

本件は社内勉強会用の機材セットを想定しています。
演習環境は社内、または自宅を前提としています。

<必須>

・本体
  今回は、Raspberry Pi 3 Model B+。
・SDカード
  最低2GB以上推奨ですが、今回はDockerも動作させるので大き目の16GB以上を推奨。
  あまり極端に大きいと動作不良があるようですのでほどほどに。
・電源ケーブル
  使い勝手を考慮して、microUSBケーブルを準備。

<環境に応じて>

・Ethernetアダプタ
  USB or Thunderboltタイプがありますが、自宅でWi-Fiしか使わない方は不要です。
・Ethernetケーブル
  こちらもWi-Fiしか使わない方は不要です。
・HDMI接続可能なモニタ
  自宅でやられる方は準備されるとデスクトップが見えるので作業が捗ります。
・HDMIケーブル
  上記とRaspberry Piを繋ぐケーブル。
  最近はTVにも端子が付いているのでそちらの利用でもOKです。
・USBキーボード/マウス
  デスクトップを操作する場合にはあった方が便利です。

Raspberry PiのOSの準備(for Mac)

下記より最新版のOSのダウンロードを行います。
  https://www.raspberrypi.org/downloads/raspbian/

色々あって迷いますが、今回は「Raspbian Stretch Lite」のZIP版をダウンロードします。
スクリーンショット 2019-05-27 11.08.50.png

ターミナルソフトを立ち上げて、以下のコマンドで解凍します。

$ unzip 2019-04-08-raspbian-stretch-lite.zip
Archive: 2019-04-08-raspbian-stretch-lite.zip
inflating: 2019-04-08-raspbian-stretch-lite.img
$

次にSDカードをMacに挿入し、SDカードのマウントポイントを確認します。
アプリケーション>ユーティリティ>ディスクユーティリティで見てみると、以下のようになっているかと思います。(SDカードのラベル名は製品によってまちまちかと)スクリーンショット 2019-05-31 16.46.44.png

diskutilコマンドで確認すると次のように見えています。
(今回は最終ブロックがSDカードです)

~ $ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.8 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.8 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            229.5 GB   disk1s1
   2:                APFS Volume Preboot                 46.8 MB    disk1s2
   3:                APFS Volume Recovery                509.8 MB   disk1s3
   4:                APFS Volume VM                      3.2 GB     disk1s4

/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:             Windows_FAT_32 SDCARD                  15.5 GB    disk2s1

マウントポイントを確認したら、次のコマンドでSDカードをアンマウントします。

~ $ sudo diskutil umount /dev/disk2s1
Password:
Volume SDCARD on disk2s1 unmounted

そうするとディスクユーティリティツール上はこんな感じになっています(アンマウント状態)スクリーンショット 2019-05-31 17.01.03.png

続けて、SDカードに下記のコマンドで書き込みを実施します。
(if=で指定しているファイル名は適宜読み替えて下さい)
(of=で指定しているディスクはdiskutil listで表示されたSDカードのデバイスを正しく指定してください。間違えると別のディスクを書き換えてしまいます!)

$ sudo dd bs=1m if=2019-04-08-raspbian-stretch-lite.img of=/dev/rdisk2

しばらくすると(15分くらい)書き込みが完了します。

1803550720 bytes transferred in 124.104657 secs (14532498 bytes/sec)

ディスクユーティリティツールで見ると、こんな感じになっています。
スクリーンショット 2019-05-31 17.07.41.png

ここでssh接続がMacから出来るようにターミナルで下記のコマンドを実行します。

$ touch /Volumes/boot/ssh

これはRaspberry Piのbootディレクトリにssh接続を許可するキッカケを与えるコマンドです。
※参考:https://www.raspberrypi.org/blog/a-security-update-for-raspbian-pixel/

補記① bootディスクがRead Onlyでファイルを作成できない場合は以下のコマンドで解除してください。
$ sudo mount -u -w /Volumes/boot
補記② Wi-Fi経由で接続したい場合は以下のconfファイルを作成してください。
$ sudo vi /Volumes/boot/wpa_supplicant.conf

country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
 ssid="<ssid>"
 psk="<pass>"
}

準備が完了したら、SDカードをMacから取り出してRaspberry Piの起動準備に取り掛かります。

ケーブル類の接続

今回は、Mac側のThunderboltをブリッジ接続してRaspberry Piをネットワークに繋ぎますので、Thunderbolt用のLANコネクタとRaspberry PiのLANポートをLANケーブルで接続(白いヤツ)。
電源はMacのUSBポートからmicroUSBメモリで頂戴することにしました。
セッティングは以下の感じです。IMG_0798.jpg

ブリッジ接続設定(for Mac)

システム環境設定>共有を開き、"サービス"部分のインターネット共有をクリック。
"相手のコンピュータでのポート"部分にある"Thunderbolt Ethernet"にチェックを付け、"サービス"の横にある"オン"のチェックを付ける。スクリーンショット 2019-05-31 22.54.54.png

Raspberry PiにmicroUSBを接続して起動します。
赤い色のランプが点き、緑色のランプが程よい間隔で点滅し出したら起動完了です。
以下のコマンドでネットワークの状況をチェックしてみます。
(結果は一部端折っています)

~ $ arp -a
? (192.168.2.1) at e2:ac:cb:66:93:64 on bridge100 ifscope permanent [bridge]
? (192.168.2.6) at b8:27:eb:82:17:50 on bridge100 ifscope [bridge]
? (192.168.2.255) at ff:ff:ff:ff:ff:ff on bridge100 ifscope [bridge]

次にifconfigコマンドでMacのネットワーク機器を確認します。
(結果は一部端折っています)

~ $ ifconfig
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 9a:00:03:78:43:b0 
    inet6 fe80::9800:3ff:fe78:43b0%bridge0 prefixlen 64 scopeid 0x9 
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    nd6 options=201<PERFORMNUD,DAD>
    media: <unknown type>
    status: inactive
bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether e2:ac:cb:66:93:64 
    inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
    inet6 fe80::e0ac:cbff:fe66:9364%bridge100 prefixlen 64 scopeid 0x11 
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en3 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 16 priority 0 path cost 0
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active

この結果から、
・ブリッジ接続はbridge100を経由して実施している
・Raspberry Piに割り当てられたアドレスは192.168.2.6っぽい
ということが推測できます。

Raspberry Piに接続してみる

ということで準備が整ったようなので、Raspberry PiにMacのターミナルから接続してみます。

sshコマンドを以下のように実行します。
ユーザー名:pi
接続先:192.168.2.6

~ $ ssh pi@192.168.2.6

もしくは、以下のようにしてもアクセス可能です。

$ ssh pi@raspberrypi.local

無事に繋がると初めての場合はフィンガープリントの登録を聞かれるので、yesで。

The authenticity of host '192.168.2.6 (192.168.2.6)' can't be established.
ECDSA key fingerprint is SHA256:ObM8Cd2P4JNcoBmBJRih7vlNHLLQyTrqee2jfbxtGVA.
Are you sure you want to continue connecting (yes/no)? yes

パスワードを聞かれますので、デフォルトの"raspberry"をタイプします。

Warning: Permanently added '192.168.2.6' (ECDSA) to the list of known hosts.
pi@192.168.2.6's password:

うまく行けば、"pi@raspberrypi:~ $ "のプロンプトが表示されます。

Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l

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

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ 

これでようやくRaspberry Piの導入と初期設定が完了です。
お疲れ様でした。

ちなみにシャットダウンコマンドは以下になります。
電源ケーブルを抜く前に実行下さい。
(でないとファイルシステムが壊れます!)

$ sudo shutdown -h now

実行後、緑色のランプのチカチカが無くなったら、microUSBケーブルを抜いてOKです。

Docker環境セットアップの情報源

公式ブログ:https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/
Docker:https://docs.docker.com/install/linux/docker-ce/debian/

Docker環境の準備(OSのバージョンをチェック)

下記のコマンドでOSのバージョンをチェックします。

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Docker環境の準備(ライブラリアップデート)

Dockerのインストール前にライブラリ群をアップデートします。

pi@raspberrypi:~ $ sudo apt-get update
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]        
Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB]   
Get:3 http://archive.raspberrypi.org/debian stretch/main armhf Packages [221 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB]
Get:5 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB]
Fetched 12.1 MB in 18s (638 kB/s)                                              
Reading package lists... Done

次に下記のコマンドを改行付きですが、一発のコマンドとして実行します。

pi@raspberrypi:~ $ sudo apt-get install --yes \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common

長いのでアレですが、結果はこんな感じになります。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (1.4.9).
ca-certificates is already the newest version (20161130+nmu1+deb9u1).
curl is already the newest version (7.52.1-5+deb9u9).
The following additional packages will be installed:
  gir1.2-glib-2.0 gir1.2-packagekitglib-1.0 libdbus-glib-1-2
  libgirepository-1.0-1 libglib2.0-bin libgstreamer1.0-0
  libpackagekit-glib2-18 packagekit packagekit-tools python3-dbus python3-gi
  python3-pycurl python3-software-properties unattended-upgrades
Suggested packages:
  gstreamer1.0-tools appstream python-dbus-doc python3-dbus-dbg
  libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg bsd-mailx
  mail-transport-agent needrestart
The following NEW packages will be installed:
  gir1.2-glib-2.0 gir1.2-packagekitglib-1.0 gnupg2 libdbus-glib-1-2
  libgirepository-1.0-1 libglib2.0-bin libgstreamer1.0-0
  libpackagekit-glib2-18 packagekit packagekit-tools python3-dbus python3-gi
  python3-pycurl python3-software-properties software-properties-common
  unattended-upgrades
0 upgraded, 16 newly installed, 0 to remove and 22 not upgraded.
Need to get 5,773 kB of archives.
After this operation, 13.4 MB of additional disk space will be used.
Get:1 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libgirepository-1.0-1 armhf 1.50.0-1 [76.4 kB]
Get:2 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf gir1.2-glib-2.0 armhf 1.50.0-1 [139 kB]
Get:4 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf gir1.2-packagekitglib-1.0 armhf 1.1.5-2+deb9u1 [34.7 kB]
Get:5 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf gnupg2 all 2.1.18-8~deb9u4 [299 kB]
Get:6 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libdbus-glib-1-2 armhf 0.108-2 [196 kB]
Get:7 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libglib2.0-bin armhf 2.50.3-2 [1,608 kB]
Get:3 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libpackagekit-glib2-18 armhf 1.1.5-2+deb9u1 [96.2 kB]
Get:8 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libgstreamer1.0-0 armhf 1.10.4-1 [1,873 kB]
Get:9 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf packagekit armhf 1.1.5-2+deb9u1 [519 kB]
Get:10 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf packagekit-tools armhf 1.1.5-2+deb9u1 [42.6 kB]
Get:11 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf python3-dbus armhf 1.2.4-1 [177 kB]
Get:12 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf python3-gi armhf 3.22.0-2 [458 kB]
Get:13 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf python3-pycurl armhf 7.43.0-2 [58.4 kB]
Get:14 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf python3-software-properties all 0.96.20.2-1 [49.5 kB]
Get:15 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf software-properties-common all 0.96.20.2-1 [83.6 kB]
Get:16 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf unattended-upgrades all 0.93.1+nmu1 [61.7 kB]
Fetched 5,773 kB in 19s (299 kB/s)                                             
Preconfiguring packages ...
Selecting previously unselected package libgirepository-1.0-1:armhf.
(Reading database ... 34734 files and directories currently installed.)
Preparing to unpack .../00-libgirepository-1.0-1_1.50.0-1_armhf.deb ...
Unpacking libgirepository-1.0-1:armhf (1.50.0-1) ...
Selecting previously unselected package gir1.2-glib-2.0:armhf.
Preparing to unpack .../01-gir1.2-glib-2.0_1.50.0-1_armhf.deb ...
Unpacking gir1.2-glib-2.0:armhf (1.50.0-1) ...
Selecting previously unselected package libpackagekit-glib2-18:armhf.
Preparing to unpack .../02-libpackagekit-glib2-18_1.1.5-2+deb9u1_armhf.deb ...
Unpacking libpackagekit-glib2-18:armhf (1.1.5-2+deb9u1) ...
Selecting previously unselected package gir1.2-packagekitglib-1.0.
Preparing to unpack .../03-gir1.2-packagekitglib-1.0_1.1.5-2+deb9u1_armhf.deb ...
Unpacking gir1.2-packagekitglib-1.0 (1.1.5-2+deb9u1) ...
Selecting previously unselected package gnupg2.
Preparing to unpack .../04-gnupg2_2.1.18-8~deb9u4_all.deb ...
Unpacking gnupg2 (2.1.18-8~deb9u4) ...
Selecting previously unselected package libdbus-glib-1-2:armhf.
Preparing to unpack .../05-libdbus-glib-1-2_0.108-2_armhf.deb ...
Unpacking libdbus-glib-1-2:armhf (0.108-2) ...
Selecting previously unselected package libglib2.0-bin.
Preparing to unpack .../06-libglib2.0-bin_2.50.3-2_armhf.deb ...
Unpacking libglib2.0-bin (2.50.3-2) ...
Selecting previously unselected package libgstreamer1.0-0:armhf.
Preparing to unpack .../07-libgstreamer1.0-0_1.10.4-1_armhf.deb ...
Unpacking libgstreamer1.0-0:armhf (1.10.4-1) ...
Selecting previously unselected package packagekit.
Preparing to unpack .../08-packagekit_1.1.5-2+deb9u1_armhf.deb ...
Unpacking packagekit (1.1.5-2+deb9u1) ...
Selecting previously unselected package packagekit-tools.
Preparing to unpack .../09-packagekit-tools_1.1.5-2+deb9u1_armhf.deb ...
Unpacking packagekit-tools (1.1.5-2+deb9u1) ...
Selecting previously unselected package python3-dbus.
Preparing to unpack .../10-python3-dbus_1.2.4-1_armhf.deb ...
Unpacking python3-dbus (1.2.4-1) ...
Selecting previously unselected package python3-gi.
Preparing to unpack .../11-python3-gi_3.22.0-2_armhf.deb ...
Unpacking python3-gi (3.22.0-2) ...
Selecting previously unselected package python3-pycurl.
Preparing to unpack .../12-python3-pycurl_7.43.0-2_armhf.deb ...
Unpacking python3-pycurl (7.43.0-2) ...
Selecting previously unselected package python3-software-properties.
Preparing to unpack .../13-python3-software-properties_0.96.20.2-1_all.deb ...
Unpacking python3-software-properties (0.96.20.2-1) ...
Selecting previously unselected package software-properties-common.
Preparing to unpack .../14-software-properties-common_0.96.20.2-1_all.deb ...
Unpacking software-properties-common (0.96.20.2-1) ...
Selecting previously unselected package unattended-upgrades.
Preparing to unpack .../15-unattended-upgrades_0.93.1+nmu1_all.deb ...
Unpacking unattended-upgrades (0.93.1+nmu1) ...
Setting up python3-pycurl (7.43.0-2) ...
Setting up libgstreamer1.0-0:armhf (1.10.4-1) ...
Setcap worked! gst-ptp-helper is not suid!
Setting up libdbus-glib-1-2:armhf (0.108-2) ...
Setting up libpackagekit-glib2-18:armhf (1.1.5-2+deb9u1) ...
Setting up libgirepository-1.0-1:armhf (1.50.0-1) ...
Setting up gnupg2 (2.1.18-8~deb9u4) ...
Setting up gir1.2-glib-2.0:armhf (1.50.0-1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for systemd (232-25+deb9u9) ...
Setting up unattended-upgrades (0.93.1+nmu1) ...

Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version

Creating config file /etc/apt/apt.conf.d/50unattended-upgrades with new version
Created symlink /etc/systemd/system/multi-user.target.wants/unattended-upgrades.service → /lib/systemd/system/unattended-upgrades.service.
Synchronizing state of unattended-upgrades.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable unattended-upgrades
Processing triggers for man-db (2.7.6.1-2) ...
Setting up gir1.2-packagekitglib-1.0 (1.1.5-2+deb9u1) ...
Setting up python3-software-properties (0.96.20.2-1) ...
Processing triggers for dbus (1.10.26-0+deb9u1) ...
Setting up libglib2.0-bin (2.50.3-2) ...
Setting up packagekit (1.1.5-2+deb9u1) ...
Setting up python3-dbus (1.2.4-1) ...
Setting up python3-gi (3.22.0-2) ...
Setting up packagekit-tools (1.1.5-2+deb9u1) ...
Setting up software-properties-common (0.96.20.2-1) ...
Processing triggers for systemd (232-25+deb9u9) ...
Processing triggers for dbus (1.10.26-0+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...

続いて次のコマンド。( add - までがコマンドです )

pi@raspberrypi:~ $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
OK

続いてフィンガープリント。

pi@raspberrypi:~ $ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

対応しているアーキテクチャの確認。

pi@raspberrypi:~ $ echo "deb [arch=armhf] https://download.docker.com/linux/debian \
>      $(lsb_release -cs) stable" | \
>     sudo tee /etc/apt/sources.list.d/docker.list
deb [arch=armhf] https://download.docker.com/linux/debian      stretch stable

パッケージリストの取得。

pi@raspberrypi:~ $ sudo apt-get update
Hit:1 http://archive.raspberrypi.org/debian stretch InRelease                  
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease               
Get:3 https://download.docker.com/linux/debian stretch InRelease [44.8 kB]
Get:4 https://download.docker.com/linux/debian stretch/stable armhf Packages [7,805 B]
Fetched 52.6 kB in 2s (20.1 kB/s)
Reading package lists... Done

Dockerのインストール

お待ちかね、Dockerのインストールです。
(ログの垂れ流しで恐縮ですが)

pi@raspberrypi:~ $ sudo apt-get install --yes docker-ce
Reading package lists... Done
Building dependency tree        
Reading state information... Done
The following additional packages will be installed:
  aufs-dkms aufs-tools cgroupfs-mount containerd.io cpp-4.6 dkms docker-ce-cli
  gcc-4.6 git git-man liberror-perl libltdl7 linux-headers-3.6-trunk-common
  linux-headers-3.6-trunk-rpi linux-kbuild-3.6 linux-kbuild-4.9 pigz
Suggested packages:
  aufs-dev gcc-4.6-locales python3-apport menu libmudflap0-4.6-dev gcc-4.6-doc
  libgcc1-dbg libgomp1-dbg libquadmath-dbg libmudflap0-dbg libcloog-ppl1
  | libcloog-ppl0 libppl-c4 libppl12 | libppl9 binutils-gold git-daemon-run
  | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch
  git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  aufs-dkms aufs-tools cgroupfs-mount containerd.io cpp-4.6 dkms docker-ce
  docker-ce-cli gcc-4.6 git git-man liberror-perl libltdl7
  linux-headers-3.6-trunk-common linux-headers-3.6-trunk-rpi linux-kbuild-3.6
  linux-kbuild-4.9 pigz
0 upgraded, 18 newly installed, 0 to remove and 22 not upgraded.
Need to get 49.2 MB of archives.
After this operation, 227 MB of additional disk space will be used.
Get:1 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf liberror-perl all 0.17024-1 [26.9 kB]
Get:2 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf git-man all 1:2.11.0-3+deb9u4 [1,433 kB]
Get:3 https://download.docker.com/linux/debian stretch/stable armhf containerd.io armhf 1.2.5-1 [10.7 MB]
Get:9 https://download.docker.com/linux/debian stretch/stable armhf docker-ce-cli armhf 5:18.09.6~3-0~debian-stretch [8,093 kB]
Get:4 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf git armhf 1:2.11.0-3+deb9u4 [3,390 kB]
Get:13 https://download.docker.com/linux/debian stretch/stable armhf docker-ce armhf 5:18.09.6~3-0~debian-stretch [10.8 MB]
Get:5 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf pigz armhf 2.3.4-1 [50.0 kB]
Get:6 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf dkms all 2.3-2 [74.8 kB]
Get:7 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf linux-kbuild-4.9 armhf 4.9.82-1+deb9u3+rpi1 [709 kB]
Get:8 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf aufs-dkms armhf 4.9+20161219-1 [169 kB]
Get:10 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf aufs-tools armhf 1:4.1+20161219-1 [101 kB]
Get:11 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf cgroupfs-mount all 1.3 [5,716 B]
Get:12 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf cpp-4.6 armhf 4.6.4-5+rpi1 [4,145 kB]
Get:12 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf cpp-4.6 armhf 4.6.4-5+rpi1 [4,145 kB]
Get:14 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf gcc-4.6 armhf 4.6.4-5+rpi1 [4,363 kB]
Get:15 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf libltdl7 armhf 2.4.6-2 [386 kB]
Get:16 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf linux-headers-3.6-trunk-common armhf 3.6.9-1~experimental.1+rpi7 [4,189 kB]
Get:16 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf linux-headers-3.6-trunk-common armhf 3.6.9-1~experimental.1+rpi7 [4,189 kB]
Get:17 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf linux-kbuild-3.6 armhf 3.6-1~experimental.1+rpi2+b2 [136 kB]
Get:18 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf linux-headers-3.6-trunk-rpi armhf 3.6.9-1~experimental.1+rpi7 [414 kB]
Fetched 43.8 MB in 1min 7s (645 kB/s)                                          
Selecting previously unselected package liberror-perl.
(Reading database ... 35203 files and directories currently installed.)
Preparing to unpack .../00-liberror-perl_0.17024-1_all.deb ...
Unpacking liberror-perl (0.17024-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../01-git-man_1%3a2.11.0-3+deb9u4_all.deb ...
Unpacking git-man (1:2.11.0-3+deb9u4) ...
Selecting previously unselected package git.
Preparing to unpack .../02-git_1%3a2.11.0-3+deb9u4_armhf.deb ...
Unpacking git (1:2.11.0-3+deb9u4) ...
Selecting previously unselected package pigz.
Preparing to unpack .../03-pigz_2.3.4-1_armhf.deb ...
Unpacking pigz (2.3.4-1) ...
Selecting previously unselected package dkms.
Preparing to unpack .../04-dkms_2.3-2_all.deb ...
Unpacking dkms (2.3-2) ...
Selecting previously unselected package linux-kbuild-4.9.
Preparing to unpack .../05-linux-kbuild-4.9_4.9.82-1+deb9u3+rpi1_armhf.deb ...
Unpacking linux-kbuild-4.9 (4.9.82-1+deb9u3+rpi1) ...
Selecting previously unselected package aufs-dkms.
Preparing to unpack .../06-aufs-dkms_4.9+20161219-1_armhf.deb ...
Unpacking aufs-dkms (4.9+20161219-1) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../07-aufs-tools_1%3a4.1+20161219-1_armhf.deb ...
Unpacking aufs-tools (1:4.1+20161219-1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../08-cgroupfs-mount_1.3_all.deb ...
Unpacking cgroupfs-mount (1.3) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../09-containerd.io_1.2.5-1_armhf.deb ...
Unpacking containerd.io (1.2.5-1) ...
Selecting previously unselected package cpp-4.6.
Preparing to unpack .../10-cpp-4.6_4.6.4-5+rpi1_armhf.deb ...
Unpacking cpp-4.6 (4.6.4-5+rpi1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../11-docker-ce-cli_5%3a18.09.6~3-0~debian-stretch_armhf.deb ...
Unpacking docker-ce-cli (5:18.09.6~3-0~debian-stretch) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../12-docker-ce_5%3a18.09.6~3-0~debian-stretch_armhf.deb ...
Unpacking docker-ce (5:18.09.6~3-0~debian-stretch) ...
Selecting previously unselected package gcc-4.6.
Preparing to unpack .../13-gcc-4.6_4.6.4-5+rpi1_armhf.deb ...
Unpacking gcc-4.6 (4.6.4-5+rpi1) ...
Selecting previously unselected package libltdl7:armhf.
Preparing to unpack .../14-libltdl7_2.4.6-2_armhf.deb ...
Unpacking libltdl7:armhf (2.4.6-2) ...
Selecting previously unselected package linux-headers-3.6-trunk-common.
Preparing to unpack .../15-linux-headers-3.6-trunk-common_3.6.9-1~experimental.1+rpi7_armhf.deb ...
Unpacking linux-headers-3.6-trunk-common (3.6.9-1~experimental.1+rpi7) ...
Selecting previously unselected package linux-kbuild-3.6.
Preparing to unpack .../16-linux-kbuild-3.6_3.6-1~experimental.1+rpi2+b2_armhf.deb ...
Unpacking linux-kbuild-3.6 (3.6-1~experimental.1+rpi2+b2) ...
Selecting previously unselected package linux-headers-3.6-trunk-rpi.
Preparing to unpack .../17-linux-headers-3.6-trunk-rpi_3.6.9-1~experimental.1+rpi7_armhf.deb ...
Unpacking linux-headers-3.6-trunk-rpi (3.6.9-1~experimental.1+rpi7) ...
Setting up aufs-tools (1:4.1+20161219-1) ...
Setting up git-man (1:2.11.0-3+deb9u4) ...
Setting up containerd.io (1.2.5-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up liberror-perl (0.17024-1) ...
Setting up cpp-4.6 (4.6.4-5+rpi1) ...
Setting up linux-headers-3.6-trunk-common (3.6.9-1~experimental.1+rpi7) ...
Setting up cgroupfs-mount (1.3) ...
Setting up dkms (2.3-2) ...
Setting up linux-kbuild-4.9 (4.9.82-1+deb9u3+rpi1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for systemd (232-25+deb9u9) ...
Setting up libltdl7:armhf (2.4.6-2) ...
Setting up gcc-4.6 (4.6.4-5+rpi1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up linux-kbuild-3.6 (3.6-1~experimental.1+rpi2+b2) ...
Setting up docker-ce-cli (5:18.09.6~3-0~debian-stretch) ...
Setting up pigz (2.3.4-1) ...
Setting up git (1:2.11.0-3+deb9u4) ...
Setting up docker-ce (5:18.09.6~3-0~debian-stretch) ...
update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Setting up aufs-dkms (4.9+20161219-1) ...
Loading new aufs-4.9+20161219 DKMS files...
It is likely that 4.14.98-v7+ belongs to a chroot's host
Building for 3.6-trunk-rpi, 4.14.98+ and 4.14.98-v7+
Building initial module for 3.6-trunk-rpi
Error!  The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which
does not match this kernel/arch.  This indicates that it should not be built.
Skipped.
Module build for kernel 4.14.98+ was skipped since the
kernel headers for this kernel does not seem to be installed.
Module build for kernel 4.14.98-v7+ was skipped since the
kernel headers for this kernel does not seem to be installed.
Setting up linux-headers-3.6-trunk-rpi (3.6.9-1~experimental.1+rpi7) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.6-trunk-rpi
Error!  The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which
does not match this kernel/arch.  This indicates that it should not be built.
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for systemd (232-25+deb9u9) ...

Dockerインストール後の確認

バージョン確認を実施します。

pi@raspberrypi:~ $ sudo docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:45:05 2019
 OS/Arch:           linux/arm
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 02:01:09 2019
  OS/Arch:          linux/arm
  Experimental:     false

現状(2019.06.03時点)は18.09.6が最新のようですね。
なお、Dockerを操作するのにsudoを付けるのが面倒くさいので、
以下のコマンドでdockerグループにユーザを追加します。
設定後に一旦ターミナルを抜けてセッションをリフレッシュします。

pi@raspberrypi:~ $ sudo usermod -aG docker ${USER}
pi@raspberrypi:~ $ exit

再度接続して、バージョンを確認してみます。

pi@raspberrypi:~ $ docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:45:05 2019
 OS/Arch:           linux/arm
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 02:01:09 2019
  OS/Arch:          linux/arm
  Experimental:     false

sudo無しで確認できました。

Docker環境の確認

hello-worldが用意されていますので、導入して稼働させてみます。

pi@raspberrypi:~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1eda109e4da: Pull complete 
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm32v7)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

pi@raspberrypi:~ $ 

という感じです。
長くなりましたが、第01回、お疲れ様でした。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1