ラズパイに入れたRocky LinuxにDockerを入れる

ラズパイにインストールしたRcoky LinuxにDockerエンジンをインストールします。公式の手順通りにやれば何のことはありません。

コンフリクトする可能性のあるパッケージを削除する

素の状態Rocky Linuxさんではありますが、公式の手順のとおりに作業します。

$ sudo dnf remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine \
                  podman \
                  runc
[sudo] password for rocky: 
No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-engine
No match for argument: podman
No match for argument: runc
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!

何も入ってなかったので、何もすることがなかったよと言われました。

リポジトリを追加する

$ sudo dnf -y install dnf-plugins-core
$ sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo

Dockerエンジンをインストール

$ sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

起動時にDockerも起動する

sudo systemctl enable --now docker

Hello worldしてみる

$ sudo docker run hello-world
[sudo] password for rocky: 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
198f93fd5094: Pull complete 
Digest: sha256:54e66cc1dd1fcb1c3c58bd8017914dbed8701e2d8c74d9262e26bd9cc1642d31
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.
    (arm64v8)
 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

Dockerをsudoなしで動かせるようにする

sudo usermod -aG docker $USER
newgrp docker

無事Dockerをインストールすることができました。