HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2017/10/01

Raspberry Piに Dockerをセットアップする方法 Raspberry Piに Dockerをセットアップする方法

(ラズパイ3に Dockerをインストールしてみる Ver 17.05.0-ce)

Tags: [Raspberry Pi], [電子工作]





● Raspberry Pi 3 Model Bを遂に購入

 Raspberry Pi3 Model B RPI2 RPI3

 大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
 以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。

 ※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
 ※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
 ※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。
 ※ 2019/06/20から Raspbian OSは Raspbian Stretchから Raspbian Busterに変わりました。

Download Raspbian for Raspberry Pi

ちなみに、歴代のバージョンと名称は
Debianコードネーム年月備考(参考)Ubuntuでの該当名称
Debian 11Bullseye2021/08/14~2021/11からラズパイにリリースFocal Fossa 20.04 LTS ?
Debian 10Buster2019/06/20~2019/06からラズパイ4対応Bionic 18.04 LTS
Debian 9Stretch2017/08/16~2018/03からラズパイ3B+対応Xenial 16.04 LTS
Debian 8Jessie2015~2016/02からラズパイ3対応Trusty 14.04 LTS
Debian 7Wheezy2013~2016
Debian 6.0Squeeze2011~2014
Debian GNU/Linux 5.0Lenny2009~2012


●ラズパイ3に Dockerをインストールする。

$ uname -a
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.1 (stretch)
Release:        9.1
Codename:       stretch


● Dockerとは?

Docker

 Docker(ドッカー)はソフトウェアコンテナ内のアプリケーションのデプロイメントを自動化するオープンソースソフトウェアである。

Docker for Debian

Docker - Docker is the world’s leading software container platform.


● Dockerのインストール方法

 raspberrypi.org公式の情報より、
DOCKER COMES TO RASPBERRY PI

 下記の 1行をコンソール(コマンドライン)で実行するだけ。
curl -sSL https://get.docker.com | sh

● Dockerのインストール後に色々と画面表示されます
sudo usermod -aG docker pi
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!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

 インストールされる Dockerのバージョン 2019/12現在
+ sudo -E sh -c docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:36:04 2019
 OS/Arch:           linux/arm
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:30:06 2019
  OS/Arch:          linux/arm
  Experimental:     false

 インストールされる Dockerのバージョン 2017/10現在
+ sudo -E sh -c docker version
Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:30:54 2017
 OS/Arch:      linux/arm

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:30:54 2017
 OS/Arch:      linux/arm
 Experimental: false

 Dockerの情報を表示
sudo docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.05.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Kernel Version: 4.9.41-v7+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 927.3MiB
Name: raspberrypi
ID: DJUT:K3HM:7C7Q:3RLY:Y7TJ:ZL5F:OSMH:TLJ6:DNYU:P5RA:WQZL:5PNH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpuset support

 ラズパイで動く Dockerイメージの一覧
Docker Hub
 Docker Hubで "rpi-"で検索する。

sudo docker search armhf-
sudo docker search rpi-
NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
armv7/armhf-ubuntu                           'official' Ubuntu Docker images for the AR...   80
container4armhf/armhf-alpine                 Automatically built base images of Alpine ...   73                   [OK]
armhf/alpine                                 A minimal Docker image based on Alpine Lin...   46
armhf/debian                                 Debian is a Linux distribution that's comp...   28
armhf/ubuntu                                 Ubuntu is a Debian-based Linux operating s...   26
ioft/armhf-ubuntu                            [ABR] Ubuntu Docker images for the ARMv7(a...   25                   [OK]
armhf/node                                   Node.js is a JavaScript-based platform for...   18
armhfbuild/nginx                             armhf fork of the official nginx Docker im...   10
armhf/python                                 Python is an interpreted, interactive, obj...   10
orax/alpine-armhf                            Daily built Alpine-Linux Docker image for ...   7                    [OK]
troyfontaine/armhf-alpinelinux               Alpine Linux for ARMHF (ARM v7l)                6
lsioarmhf/nginx-armhf                        ARMHF based Linuxserver.io image of nginx       5
forumi0721alpinearmhf/alpine-armhf-vsftpd    alpine-armhf-vsftpd                             2                    [OK]
forumi0721alpinearmhf/alpine-armhf-noip-curl alpine-armhf-noip-curl                          2                    [OK]
armhfbuild/watchtower                        Port of centurylink/watchtower to armhf         2
forumi0721alpinearmhf/alpine-armhf-nginx     alpine-armhf-nginx                              2                    [OK]
forumi0721/alpine-armhf-base                 alpine-armhf-base                               2
kennethlimcp/armhf-ghost                     The awesome Ghost blog, on armhf                1                    [OK]
snapcraft/xenial-armhf                       Docker image for building Ubuntu snaps          1                    [OK]
marcust/jessie-armhf-rust                    Debian Jessie (armhf) image containing a R...   0
marcust/xenial-armhf-rust                    Ubuntu Xenial (armhf) image containing a R...   0
marcust/trusty-armhf-rust                    Debian Trusty (armhf) image containing a R...   0
casept/debian-armhf                          A collection of minimal debian images for ...   0
adrienbrault/armhf-syncthing                 https://github.com/adrienbrault/docker-arm...   0
marcust/wily-armhf-rust                      Debian Wily (armhf) image containing a Rus...   0


● 非 rootユーザーで sudo無しで Dockerを実行する方法

 dockerコマンドの実行には root権限が必要なので sudoを付けている。
 sudoを付けるのが面倒な場合は usermodコマンドでユーザーを Dockerグループに属してあげる。
# usermodコマンドで piユーザーを dockerグループに追加する
sudo usermod -aG docker pi

# Dockerを再起動して、ログインしなおすか、
sudo systemctl restart docker

# 一旦再起動する。
sudo reboot


●ラズパイの Dockerの動作確認 docker run hello-world

docker run hello-world

● docker run hello-worldの実行結果
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1eda109e4da: Pull complete
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
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/


●ラズパイの Dockerの注意点

 x86のバイナリは動きません。
 ARM用のバイナリのみ実行可能です。



● Moby?

 Moby Dick = 白鯨


白鯨 上 (岩波文庫) 文庫 ハーマン・メルヴィル
ASIN: 4003230817

 Dockerは Moby Dickの Dickをもじった言葉なのかな。Dickを Dockにして +er。

 Mobyとは Dockerを置き換える物?

Moby project
 An open framework to assemble specialized container systems without reinventing the wheel.

moby/moby



● Dockerと似た様なアプリ rtk Rocket

rkt/rkt - rkt is a pod-native container engine for Linux. It is composable, secure, and built on standards.

Installing rkt on popular Linux distributions - Debian

sudo apt-get -y install rkt

$ rkt version
rkt Version: 1.21.0
appc Version: 0.8.9
Go Version: go1.7.4
Go OS/Arch: linux/arm
Features: -TPM +SDJOURNAL

$ rkt help
NAME:
     rkt - rkt, the application container runner

USAGE:
     rkt [command]

VERSION:
     1.21.0

COMMANDS:
     api-service             Run API service (experimental)
     cat-manifest            Inspect and print the pod manifest
     config                  Print configuration for each stage in JSON format
     enter                   Enter the namespaces of an app within a rkt pod
     export                  Export an app from an exited pod to an ACI file
     fetch                   Fetch image(s) and store them in the local store
     gc                      Garbage collect rkt pods no longer in use
     image cat-manifest      Inspect and print the image manifest
     image export            Export a stored image to an ACI file
     image extract           Extract a stored image to a directory
     image gc                Garbage collect local store
     image list              List images in the local store
     image render            Render a stored image to a directory with all its dependencies
     image rm                Remove one or more images with the given IDs or image names from the local store
     list                    List pods
     metadata-service        Run metadata service
     prepare                 Prepare to run image(s) in a pod in rkt
     rm                      Remove all files and resources associated with an exited pod
     run                     Run image(s) in a pod in rkt
     run-prepared            Run a prepared application pod in rkt
     status                  Check the status of a rkt pod
     stop                    Stop a pod
     trust                   Trust a key for image verification
     version                 Print the version and exit
     help                    Help about any command

DESCRIPTION:
     A CLI for running app containers on Linux.

     To get the help on any specific command, run "rkt help command".

OPTIONS:
   --debug[=false]                   print out more debug information to stderr
   --dir=/var/lib/rkt                rkt data directory
   --insecure-options=none           comma-separated list of security features to disable. Allowed values: "none", "image", "tls", "ondisk", "http", "pubkey", "capabilities", "paths", "seccomp", "all-fetch", "all-run", "all"
   --local-config=/etc/rkt           local configuration directory
   --system-config=/usr/lib/rkt      system configuration directory
   --trust-keys-from-https[=false]   automatically trust gpg keys fetched from https
   --user-config=                    user configuration directory

※ deb-basedの手動で debファイルをインストールする方法は Intel系 CPU用なのでラズパイでは動きません。

cd
git clone https://github.com/rkt/rkt
cd rkt

./autogen.sh
./configure

# configure: error: *** unsquashfs not found
sudo apt-get -y install squashfs-tools

# configure: error: ** No development headers for openssl found
sudo apt-get -y install libssl-dev

# configure: error: *** No development headers for libacl found
sudo apt-get -y install libacl1-dev

# configure: error: *** armv7l: no arch support for stage1 flavors {coreos,kvm,src}



●番外:Programming the Pi over USB

 Raspberry Pi Zeroを USB経由でパソコンからアクセスする方法。
 Raspberry Pi Zero / Raspberry Pi Zero Wのみ可能。Raspberry Pi 3等は動作しない。

PROGRAMMING YOUR PI ZERO OVER USB

 SDカードに OSイメージを書き込む。

/boot/config.txt
 の最後に
dtoverlay=dwc2
 を追加する。

/boot/cmdline.txt
 の rootwaitの後ろに
modules-load=dwc2,g_serial
 を追加

 つまり、
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=1d05ff45-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
 が
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=1d05ff45-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial quiet splash plymouth.ignore-serial-consoles
 になる。


 Windows 7の USB Ethernet RNDISドライバ。
Acer Incorporated. - Other hardware - USB Ethernet/RNDIS Gadget
 Acer Incorporated. - Other hardware - Acer Netchip RNDIS/Ethernet Gadget
 最終変更日時: 2010/01/13
 サイズ: 21 KB
 サポートされている製品: Windows 7 , Windows 8 , Windows 8.1 and later drivers
 サポートされているハードウェア ID - usb\vid_0502&pid_3210
20342322_4b9970e3174b23b5cb2371af0837f939a71271ea.cab



Tags: [Raspberry Pi], [電子工作]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

FWinSdCardImager SDカード イメージ書き込みアプリ、ラズパイの Raspbian OS、Jetson Nanoの Ubuntuの書き込みに便利
FWinSdCardImager SDカード イメージ書き込みアプリ、ラズパイの Raspbian OS、Jetson Nanoの Ubuntuの書き込みに便利

  ラズパイや Jetson Nano等のワンボードマイコン等への OSイメージの書き込みが簡単にできる

FWinPiFinder ラズベリーパイ IPアドレス発見アプリ。ARPコマンドでラズパイの IPアドレスを探索発見する
FWinPiFinder ラズベリーパイ IPアドレス発見アプリ。ARPコマンドでラズパイの IPアドレスを探索発見する

  Raspberry Piや NVIDIA Jetson Nano等の IPアドレスを MACアドレスの OUI部分を使用して発見する

Raspberry Pi 3系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ
Raspberry Pi 3系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ

  ラズパイ3B系での低電圧警報に関する情報まとめ、コマンドラインやログファイルから低電圧を検知する方法

Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法
Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法

  ラズパイで 2018年初頭に大騒ぎになったスペクターとメルトダウンの CPUの脆弱性をチェックする方法

Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入できる通販ショップ一覧まとめ
Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入できる通販ショップ一覧まとめ

  ラズパイゼロW ワイヤレスモデルを海外通販でサクッと簡単に個人輸入で入手。技適通過でも国内販売は常に品切れ

Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ
Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ

  ラズパイ3で安定して使える microSDカードを購入する Teamと SanDiskは絶対に買わない

Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法

  ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法

Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ

  ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も

Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳
Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳

  ラズパイ公式フォーラムの「The Raspberry Pi 3 Model B Q&A thread」の日本語訳

Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法

  ラズパイ3の GPIO端子の I2C機能を有効にして各種センサーを繋げる方法まとめ

大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう
大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう

  Raspberry Piの開発環境の構築やタッチパネル付き液晶ディスプレイや各種センサーの使い方まとめ


Raspberry Pi 3、シングルボードコンピュータ ラズパイ3 Raspberry Pi関連はこちらへまとめました
 下記以外にも多数のラズパイ関係の記事が有ります。
 (I2C制御、GPIO制御、1-Wire制御、シリアル通信、日本語音声合成、日本語音声認識、中国語音声合成、MeCab 形態素解析エンジン、赤外線リモコン制御、秋月 I2C液晶モジュール、KeDei 3.5インチ液晶、HDMI 5インチ液晶、NFCカードリーダ、コマンドライン操作方法等)
Raspberry Pi 3に HDMI接続の 800x480 5インチ TFT液晶を接続して使用する方法
Raspberry Pi Raspbian Jessie 2017-07最終版で LIRCを使って学習リモコン、赤外線リモコンを送受信する方法
Raspberry Pi 3の WiFiを広告ブロック機能付きの無線LANアクセスポイント化 hostapd + dnsmasq編
Raspberry Pi 3の Bluetoothで ブルテザで通信する方法(Bluetooth編)
Raspberry Pi 3で日本語音声を合成して喋らせる方法(OpenJTalk編)
Raspberry Pi 3に USB Micを接続して日本語の音声認識をする方法(Julius編)
Raspberry Pi 3の GPIOに LEDとスイッチを接続して Lチカする方法
Raspberry Pi 3の GPIOに LEDとスイッチを接続してシャットダウンボタンを実装する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3の GPIOに I2C通信方式の気圧計 BMP280を接続する方法
Raspberry Pi 3に I2C通信方式の NFCリーダライタ PN532を接続して NFC FeliCaカードを読む方法
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 Motion編
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 MJPG-streamer編
Raspberry Pi 3 Model Bで動画処理アプリ FFmpegをコンパイルする方法
Raspberry Pi3の X-Window Systemに Windowsのリモートデスクトップから接続する方法
Raspberry Pi3に WebRTCの STUN/TRUNサーバと PeerJSサーバをインストールする方法
【成功版】Raspberry Piで NNPACK対応版の Darknet Neural Network Frameworkをビルドする方法


Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板
Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板

  Espressif ESP8266 ESP-12-E NodeMCU V1 ESP12 CP2102

BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)
BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)

  レーザー彫刻機、カラー液晶の DIYオシロ、Arduinoや Raspberry Pi用の小型カラー液晶




[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2017 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_docker/