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?

Rocky Linux 9にDocker Engineをインストールする

Posted at

What's?

以前、AlmaLinux 9にDocker Engineをインストールする記事を書きました。

この時、Docker EngineのRed Hat Enterprise Linux(以降RHEL)向けのインストール手順を見ると、以下のように書かれていていかにも使わない方がよさそうな感じで書かれていました。

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.

というわけでこの時点ではPodmanを使った方がよいのだろうと思っていたのですが、今見るとこの記述がなくなっていたので確認してみることにしました。

実際には、RHELではなくRocky Linux 9にDocker Engineをインストールしてみたいと思います。

Docker EngineとRed Hat Enterprise Linux

Docker EngineのRHEL向けのインストール手順を見てみます。

ひとまず以前のような文は書かれていませんね。いつからなくなったんでしょうか?

ドキュメントのコミット履歴を見ると、2024年6月に記述が変わっていたようです。

よくよく見ると現時点でも実験的サポートの位置づけになっている気もするのですが、ドキュメント上はそれがわかりません。

リリースノートを見てもハッキリとはしませんが、Docker Engine 27以降の話のような気がします。
https://docs.docker.com/engine/release-notes/27/

ひとまず、以前よりは使っても大丈夫そうですね。対象はRHEL 8と9になります。

ちなみにCentOSのページを見てみると、CentOS Stream 9が対象です。

環境

今回の環境はこちらです。Rocky Linux 9.6です。

$ cat /etc/redhat-release
Rocky Linux release 9.6 (Blue Onyx)


$ uname -srvmpio
Linux 5.14.0-570.22.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 18 17:59:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Rocky Linux 9にDocker Engineをインストールする

それでは、こちらの手順に沿ってRocky Linux 9にDocker Engineをインストールしてみます。

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

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

リポジトリの追加。

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

Docker Engineのインストール。

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

systemdでの有効化と起動。

$ sudo systemctl enable --now docker

ステータスを確認。

$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-06-21 19:38:11 JST; 20s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 3200 (dockerd)
      Tasks: 9
     Memory: 23.8M
        CPU: 239ms
     CGroup: /system.slice/docker.service
             └─3200 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

 6月 21 19:38:09 rocky9.localdomain dockerd[3200]: time="2025-06-21T19:38:09.147022666+09:00" level=info msg="Creating a containerd client" address=/run/containerd/contain>
 6月 21 19:38:09 rocky9.localdomain dockerd[3200]: time="2025-06-21T19:38:09.302053996+09:00" level=info msg="Loading containers: start."
 6月 21 19:38:09 rocky9.localdomain dockerd[3200]: time="2025-06-21T19:38:09.400683912+09:00" level=info msg="Firewalld: created docker-forwarding policy"
 6月 21 19:38:10 rocky9.localdomain dockerd[3200]: time="2025-06-21T19:38:10.744179821+09:00" level=info msg="Loading containers: done."

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

$ sudo usermod -aG docker $USER

新しくシェルを起動して、nginxコンテナを起動。

$ docker container run -it --rm -p 80:80 nginx:1.27.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
2025/06/21 10:45:17 [notice] 1#1: using the "epoll" event method
2025/06/21 10:45:17 [notice] 1#1: nginx/1.27.1
2025/06/21 10:45:17 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2025/06/21 10:45:17 [notice] 1#1: OS: Linux 5.14.0-570.22.1.el9_6.x86_64
2025/06/21 10:45:17 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1073741816:1073741816
2025/06/21 10:45:17 [notice] 1#1: start worker processes
2025/06/21 10:45:17 [notice] 1#1: start worker process 29
2025/06/21 10:45:17 [notice] 1#1: start worker process 30

確認。

$ 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:           28.1.1
 API version:       1.49
 Go version:        go1.23.8
 Git commit:        4eba377
 Built:             Fri Apr 18 09:54:03 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.1.1
  API version:      1.49 (minimum version 1.24)
  Go version:       go1.23.8
  Git commit:       01f442b
  Built:            Fri Apr 18 09:52:20 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker Composeのバージョンも確認しておきます。

$ docker compose version
Docker Compose version v2.35.1

OKですね。

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?