Raspberry Pi に docker をインストールする

環境

pi@pi:~/package $ uname -a
Linux pi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux
pi@pi:~/package $ cat /etc/issue
Raspbian GNU/Linux 11 \n \l
pi@pi:~/package $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

docs.docker.com

こちらを実行する

1 cleanup

pi@pi:~/package $ sudo apt-get remove docker docker-engine docker.io containerd runc
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package docker-engine

2. package install

pi@pi:~/package $ sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
Get:1 http://archive.raspberrypi.org/debian bullseye InRelease [23.6 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:4 http://archive.raspberrypi.org/debian bullseye/main armhf Packages [311 kB]
Fetched 13.6 MB in 11s (1,187 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20210119).
curl is already the newest version (7.74.0-1.3+deb11u3).
gnupg is already the newest version (2.2.27-2+deb11u2).
lsb-release is already the newest version (11.1.0+rpi1).
lsb-release set to manually installed.
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 110 not upgraded.

3. Add GPG Key, set up the repository

pi@pi:~/package $ sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
pi@pi:~/package $ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
pi@pi:~/package $ sudo apt-get update
Get:1 https://download.docker.com/linux/debian bullseye InRelease [43.3 kB]
Get:2 https://download.docker.com/linux/debian bullseye/stable armhf Packages [15.3 kB]
Hit:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Hit:4 http://archive.raspberrypi.org/debian bullseye InRelease
Fetched 58.6 kB in 7s (8,791 B/s)
Reading package lists... Done

4. docker install

pi@pi:~/package $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  apparmor docker-ce-rootless-extras libslirp0 slirp4netns
Suggested packages:
  apparmor-profiles-extra apparmor-utils cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
  apparmor containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin libslirp0 slirp4netns
0 upgraded, 8 newly installed, 0 to remove and 110 not upgraded.
Need to get 87.2 MB of archives.
After this operation, 353 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://download.docker.com/linux/debian bullseye/stable armhf containerd.io armhf 1.6.14-1 [20.4 MB]
Get:2 http://ftp.udx.icscoe.jp/Linux/raspbian/raspbian bullseye/main armhf apparmor armhf 2.13.6-10 [532 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libslirp0 armhf 4.4.0-1+deb11u2 [50.2 kB]
Get:4 https://download.docker.com/linux/debian bullseye/stable armhf docker-ce-cli armhf 5:20.10.22~3-0~debian-bullseye [37.5 MB]
Get:5 http://ftp.udx.icscoe.jp/Linux/raspbian/raspbian bullseye/main armhf slirp4netns armhf 1.0.1-2 [29.0 kB]
Get:6 https://download.docker.com/linux/debian bullseye/stable armhf docker-ce armhf 5:20.10.22~3-0~debian-bullseye [13.1 MB]
Get:7 https://download.docker.com/linux/debian bullseye/stable armhf docker-ce-rootless-extras armhf 5:20.10.22~3-0~debian-bullseye [7,442 kB]
Get:8 https://download.docker.com/linux/debian bullseye/stable armhf docker-compose-plugin armhf 2.14.1~debian-bullseye [8,218 kB]
Fetched 87.2 MB in 8s (11.4 MB/s)
Preconfiguring packages ...
Selecting previously unselected package apparmor.
(Reading database ... 108020 files and directories currently installed.)
Preparing to unpack .../0-apparmor_2.13.6-10_armhf.deb ...
Unpacking apparmor (2.13.6-10) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../1-containerd.io_1.6.14-1_armhf.deb ...
Unpacking containerd.io (1.6.14-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../2-docker-ce-cli_5%3a20.10.22~3-0~debian-bullseye_armhf.deb ...
Unpacking docker-ce-cli (5:20.10.22~3-0~debian-bullseye) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../3-docker-ce_5%3a20.10.22~3-0~debian-bullseye_armhf.deb ...
Unpacking docker-ce (5:20.10.22~3-0~debian-bullseye) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../4-docker-ce-rootless-extras_5%3a20.10.22~3-0~debian-bullseye_armhf.deb ...
Unpacking docker-ce-rootless-extras (5:20.10.22~3-0~debian-bullseye) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../5-docker-compose-plugin_2.14.1~debian-bullseye_armhf.deb ...
Unpacking docker-compose-plugin (2.14.1~debian-bullseye) ...
Selecting previously unselected package libslirp0:armhf.
Preparing to unpack .../6-libslirp0_4.4.0-1+deb11u2_armhf.deb ...
Unpacking libslirp0:armhf (4.4.0-1+deb11u2) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../7-slirp4netns_1.0.1-2_armhf.deb ...
Unpacking slirp4netns (1.0.1-2) ...
Setting up apparmor (2.13.6-10) ...
Created symlink /etc/systemd/system/sysinit.target.wants/apparmor.service → /lib/systemd/system/apparmor.service.
Setting up containerd.io (1.6.14-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.14.1~debian-bullseye) ...
Setting up docker-ce-cli (5:20.10.22~3-0~debian-bullseye) ...
Setting up libslirp0:armhf (4.4.0-1+deb11u2) ...
Setting up docker-ce-rootless-extras (5:20.10.22~3-0~debian-bullseye) ...
Setting up slirp4netns (1.0.1-2) ...
Setting up docker-ce (5:20.10.22~3-0~debian-bullseye) ...
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.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u4) ...

5. run hello world

pi@pi:~/package $ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
04341b189be6: Pull complete
Digest: sha256:94ebc7edf3401f299cd3376a1669bc0a49aef92d6d2669005f9bc5ef028dc333
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/

インストール完了