0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AlmaLinux 9にDocker Engine(Docker CE)をインストールする

Last updated at Posted at 2023-07-02

What's?

AlmaLinux 9にDocker Engine(Docker CE)はインストールできましたっけ?ということで、試してみました。

その前に

Red Hat Enterprise Linux 8以降、Dockerは削除されました。

RHEL 8.0 には、Docker が同梱されていません。コンテナーを使用するには、ツールの podman、buildah、skopeo、および runc が必要です。

代わりにPodmanを使うことになっています。

コンテナまわりのドキュメントを見ると、「対応していません」とハッキリ言い切っていますね。

Red Hat では、RHEL 8 から Docker コンテナーエンジンと、docker コマンドが削除されました。

RHEL で Docker を使用する場合は、異なるアップストリームプロジェクトから Docker を取得できますが、RHEL 8 では対応していません。

というわけで、本来はPodmanを選択するのが筋です。

Podmanについては、またそのうち扱おうかなと思います。

今回はRed Hat Enterprise LinuxおよびそのクローンのDocker事情を見ていったことに意味があったかなと思います。

環境

今回の環境は、こちらです。

$ cat /etc/redhat-release
AlmaLinux release 9.2 (Turquoise Kodkod)


$ cat /etc/os-release
NAME="AlmaLinux"
VERSION="9.2 (Turquoise Kodkod)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.2 (Turquoise Kodkod)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"


$ uname -srvmpio
Linux 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Docker Engineのドキュメントを見る

まずはDocker Engineのドキュメントを見てみます。

Red Hat Enterprise Linux向けのインストールガイド。

IBM Z向けのパッケージが提供されているのみで、他のアーキテクチャーはサポートされていないようです。
「CentOS向けのパッケージでインストールできるかもしれない」くらいの表現になっていますね。

We currently only provide packages for RHEL on s390x (IBM Z). Other architectures are not yet supported for RHEL, but you may be able to install the CentOS packages on RHEL. Refer to the Install Docker Engine on CentOS page for details.

対象のバージョン。

  • RHEL 7 on s390x (IBM Z)
  • RHEL 8 on s390x (IBM Z)
  • RHEL 9 on s390x (IBM Z)

というわけで、CentOSの方を見てみましょう。

対応しているバージョンは、こちら。

  • CentOS 7
  • CentOS 8 (stream)
  • CentOS 9 (stream)

CentOS 8以降は、CentOS Streamを対象にしています。

こうなると、基本的にRed Hat Enterprise Linux 8以降にはDocker Engineとしても対応していないと思った方がよさそうですね。

それでもインストールしてみる

ここまで見てきたので、せっかくなのでインストールしてどうなるかまで見てみました。

CentOS向けの手順に沿って実行していきます。yumdnfに読み替えました。

古いパッケージのアンインストール。

$ sudo dnf remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

リポジトリの追加。

$ sudo dnf install yum-utils
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Docker Engine(Docker CE)のインストール。

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

起動。

$ sudo systemctl start docker

ステータスを確認。

$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: disabled)
     Active: active (running) since Mon 2023-07-03 01:15:49 JST; 1s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 30147 (dockerd)
      Tasks: 9
     Memory: 28.9M
        CPU: 457ms
     CGroup: /system.slice/docker.service
             └─30147 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

ここで先に、sudoなしでdockerコマンドを実行できるようにしておきましょう。

ユーザーをdockerグループに追加。

$ sudo usermod -aG docker $USER

1度シェルからログアウトして、再度シェルを起動します。

nginxコンテナを起動。

$ docker container run -it --rm -p 80:80 nginx:1.25.1

立ち上がりました。

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/07/02 16:16:34 [notice] 1#1: using the "epoll" event method
2023/07/02 16:16:34 [notice] 1#1: nginx/1.25.1
2023/07/02 16:16:34 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2023/07/02 16:16:34 [notice] 1#1: OS: Linux 5.14.0-284.11.1.el9_2.x86_64
2023/07/02 16:16:34 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1073741816:1073741816
2023/07/02 16:16:34 [notice] 1#1: start worker processes
2023/07/02 16:16:34 [notice] 1#1: start worker process 30
2023/07/02 16:16:34 [notice] 1#1: start worker process 31

アクセスもできました。

$ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

インストールされたDocker Engineのバージョン確認。

$ docker version
Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:24 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:51:50 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker Compose。

$ docker compose version
Docker Compose version v2.18.1

蛇足

というわけで、Docker Engine(Docker CE)をAlmaLinux 9にインストールしてみました。

動きはしましたが、Red Hat Enterprise Linux 8以降のDockerの対応状況が厳しそうなことがよくわかったので、Podmanを使うことになるでしょうね…。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?