雑木林

頭の中の整理と忘れないための確認メモ

rasbian(buster)にdockerをインストールする

タイトルの通り。 raspberry pi 3が半年以上放置されていたので活用目的で構築してみました。
インストール方法はいくつかあるのですが、色々はまったので備忘録を残します。

(成功事例)スクリプトを使ったインストール

こちらを参考に、少しだけアレンジが必要です。
rasbian(buster)用のファイルはstable版がまだないため、nightlyチャネルからインストールします。

$ curl -fsSL get.docker.com | CHANNEL=nightly sh
# Executing docker install script, commit: 6bf300318ebaab958c4adc341a8c7bb9f3a54a1a
+ sudo -E sh -c apt-get update -qq >/dev/null

(省略)

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.

piユーザでdockerコマンドが使えるようにします。

$ sudo usermod -a -G docker pi

docker-composeはaptからインストールしたものが利用可能です。

$ sudo apt install docker-compose
(省略)

動作確認します。

$ docker -v
Docker version 0.0.0-20190719010106-7606ffb, build 7606ffb

$ docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1eda109e4da: Pull complete
Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
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/

一部気になる挙動もありますが、概ね動いている模様。
stable版が早いこと出てくれることを願ってます。
以下は失敗事例です。

(失敗事例)aptを使ったインストール

インストール直後の状態でもaptコマンドでdockerはインストール可能です。

$ sudo apt install docker docker-compose
(省略)

$ sudo docker -v
Docker version 18.09.1, build 4c52b90

ただ、バグを内在しているようで動作しません。

$ docker run --rm --name apline01 -it alpine:latest /bin/sh
docker: Error response from daemon: unable to find "net_prio" in controller set: unknown.

(失敗事例)公式ドキュメントを流し読みしてインストール

公式のリポジトリ追加で行う方法は使用できません。

Get Docker CE for Debian | Docker Documentation

ちゃんと "Rasbianユーザには使えないのでスクリプト使ってね" と書いてある 。

Raspbian users cannot use this method!
For Raspbian, installing using the repository is not yet supported. You must instead use the convenience script.

やってみるとこんな感じのエラーになります。
以下はraspbian側のリポジトリを登録しようとしてますが、URLをdebianのものにしても同じでした。

$ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo apt-key add -
OK

$ sudo add-apt-repository    "deb [arch=armhf] https://download.docker.com/linux/raspbian \
   $(lsb_release -cs) \
   nightly"
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 95, in <module>
    sp = SoftwareProperties(options=options)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 109, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 599, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 93, in get_sources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Raspbian/buster