LoginSignup
38
47

More than 5 years have passed since last update.

Raspberry Pi 3 Model B(Raspbian)にDockerをインストールする

Last updated at Posted at 2017-06-20

RaspbianがインストールされたRaspberry Pi 3 Model BにDockerをインストールした際のメモです。
特にハマる事も無く、公式ドキュメント『Get Docker for Debian | Docker Documentation』に従ってインストールするだけで、問題無く動作しました。

インストールからバージョン確認まで

# Raspberry Piに接続する。mDNS名称を使う。
macOS$ ssh pi@raspberrypi.local

# OSのバージョンを確認する。
pi@raspberrypi$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
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"

# 公式ドキュメントに従ってインストールする。「arch=armhf」を指定すること。
pi@raspberrypi$ sudo apt-get update
pi@raspberrypi$ sudo apt-get install --yes \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common
pi@raspberrypi$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
pi@raspberrypi$ sudo apt-key fingerprint 0EBFCD88
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
pi@raspberrypi$ sudo apt-get update
pi@raspberrypi$ sudo apt-get install --yes docker-ce

# Dockerのバージョンを確認する。(まだdockerグループに追加していないのでsudo付き)
pi@raspberrypi$ sudo docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:13:32 2017
 OS/Arch:      linux/arm

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:13:32 2017
 OS/Arch:      linux/arm
 Experimental: false

# dockerグループにユーザを追加する。
pi@raspberrypi$ sudo usermod -aG docker ${USER}

# dockerグループへの追加を反映するため、セッションを再起動(再ログイン)する。

# Dockerのバージョンを確認する。(dockerグループに追加したのでsudoなし)
pi@raspberrypi$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:13:32 2017
 OS/Arch:      linux/arm

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:13:32 2017
 OS/Arch:      linux/arm
 Experimental: false

hello-world

2018年10月25日更新:

動作確認によく使用されるhello-worldイメージですが、x86_64アーキテクチャのイメージであるため、armhfアーキテクチャであるRaspberry Pi上では残念ながら動作しません。

動作確認によく使用されるhello-worldイメージがマルチアーキテクチャ対応になったため、Raspberry Pi上でも動作するようになりました。

pi@raspberrypi$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
61e750ce94d2: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
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/

2018年10月25日追記: Raspberry Pi 3 Model B+ & Raspbian GNU/Linux 9 (stretch)

より新しい「Raspberry Pi 3 Model B+」と「Raspbian GNU/Linux 9 (stretch)」でも動作しました。

pi@raspberrypi$ uname -a
Linux raspberrypi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux

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"

pi@raspberrypi$ docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:30:49 2018
 OS/Arch:           linux/arm
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:26:32 2018
  OS/Arch:          linux/arm
  Experimental:     false
38
47
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
38
47