目的
CentOS のサポート終了に伴って、環境の移行を実施中。
docker と docker-compse を CentOS で実行している環境があり、その環境の引継ぎ用に Miracle Linux へ docker、docker-compoer 環境の作成を行ってみる。
注意事項
コマンドはいろいろと調べていたので、本記事は実行コマンドと実行ログの記録のみとしています。
docker の設定
リポジトリのインストール
コマンド
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
実行ログ
[root@test244 ~]# sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo repo の追加: https://download.docker.com/linux/centos/docker-ce.repo [root@test244 ~]#
リポジトリの確認
コマンド
dnf repolist
実行ログ
[root@test244 ~]# dnf repolist repo id repo の名前 8-latest-AppStream 8-latest-AppStream 8-latest-BaseOS 8-latest-BaseOS docker-ce-stable Docker CE Stable - x86_64 [root@test244 ~]#
docker-ce-stable が表示されていればOKとする。
docker のインストール
実行コマンド
sudo dnf -y install docker-ce
実行ログ
[root@test244 ~]# sudo dnf -y install docker-ce Docker CE Stable - x86_64 4.9 kB/s | 50 kB 00:10 8-latest-BaseOS 425 B/s | 4.3 kB 00:10 8-latest-BaseOS 2.2 MB/s | 44 MB 00:19 8-latest-AppStream 469 B/s | 4.7 kB 00:10 8-latest-AppStream 2.5 MB/s | 51 MB 00:20 依存関係が解決しました。 ========================================================================================================= パッケージ Arch バージョン リポジトリー サイズ ========================================================================================================= インストール: docker-ce x86_64 3:24.0.6-1.el8 docker-ce-stable 24 M 依存関係のインストール: checkpolicy x86_64 2.9-1.el8 8-latest-BaseOS 346 k container-selinux noarch 2:2.205.0-2.module+el8+1646+e7d22cc1 8-latest-AppStream 63 k containerd.io x86_64 1.6.24-3.1.el8 docker-ce-stable 34 M docker-ce-cli x86_64 1:24.0.6-1.el8 docker-ce-stable 7.2 M docker-ce-rootless-extras x86_64 24.0.6-1.el8 docker-ce-stable 4.9 M fuse-common x86_64 3.3.0-16.el8 8-latest-BaseOS 21 k fuse-overlayfs x86_64 1.11-1.module+el8+1646+e7d22cc1 8-latest-AppStream 73 k fuse3 x86_64 3.3.0-16.el8 8-latest-BaseOS 53 k fuse3-libs x86_64 3.3.0-16.el8 8-latest-BaseOS 94 k libcgroup x86_64 0.41-19.el8 8-latest-BaseOS 69 k libslirp x86_64 4.4.0-1.module+el8+1646+e7d22cc1 8-latest-AppStream 69 k policycoreutils-python-utils noarch 2.9-19.el8 8-latest-BaseOS 252 k python3-audit x86_64 3.0.7-2.el8.2.ML.1 8-latest-BaseOS 86 k python3-libsemanage x86_64 2.9-8.el8.ML.1 8-latest-BaseOS 127 k python3-policycoreutils noarch 2.9-19.el8 8-latest-BaseOS 2.2 M python3-setools x86_64 4.3.0-3.el8 8-latest-BaseOS 623 k slirp4netns x86_64 1.2.0-2.module+el8+1646+e7d22cc1 8-latest-AppStream 53 k 弱い依存関係のインストール: docker-buildx-plugin x86_64 0.11.2-1.el8 docker-ce-stable 13 M docker-compose-plugin x86_64 2.21.0-1.el8 docker-ce-stable 13 M モジュールストリームの有効化中: container-tools rhel8 トランザクションの概要 ========================================================================================================= インストール 20 パッケージ ダウンロードサイズの合計: 100 M インストール後のサイズ: 378 M パッケージのダウンロード: (1/20): docker-buildx-plugin-0.11.2-1.el8.x86_64.rpm 1.6 MB/s | 13 MB 00:08 (2/20): docker-ce-cli-24.0.6-1.el8.x86_64.rpm 3.8 MB/s | 7.2 MB 00:01 (3/20): docker-ce-rootless-extras-24.0.6-1.el8.x86_64.rpm 3.1 MB/s | 4.9 MB 00:01 (4/20): containerd.io-1.6.24-3.1.el8.x86_64.rpm 2.6 MB/s | 34 MB 00:13 (5/20): docker-ce-24.0.6-1.el8.x86_64.rpm 1.8 MB/s | 24 MB 00:13 (6/20): docker-compose-plugin-2.21.0-1.el8.x86_64.rpm 4.8 MB/s | 13 MB 00:02 (7/20): fuse-common-3.3.0-16.el8.x86_64.rpm 3.7 kB/s | 21 kB 00:05 (8/20): fuse3-3.3.0-16.el8.x86_64.rpm 10 kB/s | 53 kB 00:05 (9/20): checkpolicy-2.9-1.el8.x86_64.rpm 55 kB/s | 346 kB 00:06 (10/20): fuse3-libs-3.3.0-16.el8.x86_64.rpm 1.5 MB/s | 94 kB 00:00 (11/20): libcgroup-0.41-19.el8.x86_64.rpm 706 kB/s | 69 kB 00:00 (12/20): policycoreutils-python-utils-2.9-19.el8.noarch.rpm 2.2 MB/s | 252 kB 00:00 (13/20): python3-audit-3.0.7-2.el8.2.ML.1.x86_64.rpm 817 kB/s | 86 kB 00:00 (14/20): python3-libsemanage-2.9-8.el8.ML.1.x86_64.rpm 1.8 MB/s | 127 kB 00:00 (15/20): python3-setools-4.3.0-3.el8.x86_64.rpm 4.5 MB/s | 623 kB 00:00 (16/20): container-selinux-2.205.0-2.module+el8+1646+e7d22cc1.noarch.rpm 440 kB/s | 63 kB 00:00 (17/20): libslirp-4.4.0-1.module+el8+1646+e7d22cc1.x86_64.rpm 964 kB/s | 69 kB 00:00 (18/20): fuse-overlayfs-1.11-1.module+el8+1646+e7d22cc1.x86_64.rpm 732 kB/s | 73 kB 00:00 (19/20): slirp4netns-1.2.0-2.module+el8+1646+e7d22cc1.x86_64.rpm 981 kB/s | 53 kB 00:00 (20/20): python3-policycoreutils-2.9-19.el8.noarch.rpm 6.2 MB/s | 2.2 MB 00:00 --------------------------------------------------------------------------------------------------------- 合計 3.3 MB/s | 100 MB 00:30 Docker CE Stable - x86_64 317 B/s | 1.6 kB 00:05 GPG 鍵 0x621E9F35 をインポート中: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 From : https://download.docker.com/linux/centos/gpg 鍵のインポートに成功しました トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 インストール中 : fuse3-libs-3.3.0-16.el8.x86_64 1/20 scriptletの実行中: fuse3-libs-3.3.0-16.el8.x86_64 1/20 インストール中 : docker-compose-plugin-2.21.0-1.el8.x86_64 2/20 scriptletの実行中: docker-compose-plugin-2.21.0-1.el8.x86_64 2/20 インストール中 : libslirp-4.4.0-1.module+el8+1646+e7d22cc1.x86_64 3/20 インストール中 : slirp4netns-1.2.0-2.module+el8+1646+e7d22cc1.x86_64 4/20 インストール中 : python3-setools-4.3.0-3.el8.x86_64 5/20 インストール中 : python3-libsemanage-2.9-8.el8.ML.1.x86_64 6/20 インストール中 : python3-audit-3.0.7-2.el8.2.ML.1.x86_64 7/20 scriptletの実行中: libcgroup-0.41-19.el8.x86_64 8/20 インストール中 : libcgroup-0.41-19.el8.x86_64 8/20 scriptletの実行中: libcgroup-0.41-19.el8.x86_64 8/20 インストール中 : fuse-common-3.3.0-16.el8.x86_64 9/20 インストール中 : fuse3-3.3.0-16.el8.x86_64 10/20 インストール中 : fuse-overlayfs-1.11-1.module+el8+1646+e7d22cc1.x86_64 11/20 scriptletの実行中: fuse-overlayfs-1.11-1.module+el8+1646+e7d22cc1.x86_64 11/20 インストール中 : checkpolicy-2.9-1.el8.x86_64 12/20 インストール中 : python3-policycoreutils-2.9-19.el8.noarch 13/20 インストール中 : policycoreutils-python-utils-2.9-19.el8.noarch 14/20 scriptletの実行中: container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch 15/20 インストール中 : container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch 15/20 scriptletの実行中: container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch 15/20 インストール中 : containerd.io-1.6.24-3.1.el8.x86_64 16/20 scriptletの実行中: containerd.io-1.6.24-3.1.el8.x86_64 16/20 インストール中 : docker-buildx-plugin-0.11.2-1.el8.x86_64 17/20 scriptletの実行中: docker-buildx-plugin-0.11.2-1.el8.x86_64 17/20 インストール中 : docker-ce-cli-1:24.0.6-1.el8.x86_64 18/20 scriptletの実行中: docker-ce-cli-1:24.0.6-1.el8.x86_64 18/20 インストール中 : docker-ce-rootless-extras-24.0.6-1.el8.x86_64 19/20 scriptletの実行中: docker-ce-rootless-extras-24.0.6-1.el8.x86_64 19/20 インストール中 : docker-ce-3:24.0.6-1.el8.x86_64 20/20 scriptletの実行中: docker-ce-3:24.0.6-1.el8.x86_64 20/20 scriptletの実行中: container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch 20/20 scriptletの実行中: docker-ce-3:24.0.6-1.el8.x86_64 20/20 検証 : containerd.io-1.6.24-3.1.el8.x86_64 1/20 検証 : docker-buildx-plugin-0.11.2-1.el8.x86_64 2/20 検証 : docker-ce-3:24.0.6-1.el8.x86_64 3/20 検証 : docker-ce-cli-1:24.0.6-1.el8.x86_64 4/20 検証 : docker-ce-rootless-extras-24.0.6-1.el8.x86_64 5/20 検証 : docker-compose-plugin-2.21.0-1.el8.x86_64 6/20 検証 : checkpolicy-2.9-1.el8.x86_64 7/20 検証 : fuse-common-3.3.0-16.el8.x86_64 8/20 検証 : fuse3-3.3.0-16.el8.x86_64 9/20 検証 : fuse3-libs-3.3.0-16.el8.x86_64 10/20 検証 : libcgroup-0.41-19.el8.x86_64 11/20 検証 : policycoreutils-python-utils-2.9-19.el8.noarch 12/20 検証 : python3-audit-3.0.7-2.el8.2.ML.1.x86_64 13/20 検証 : python3-libsemanage-2.9-8.el8.ML.1.x86_64 14/20 検証 : python3-policycoreutils-2.9-19.el8.noarch 15/20 検証 : python3-setools-4.3.0-3.el8.x86_64 16/20 検証 : container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch 17/20 検証 : fuse-overlayfs-1.11-1.module+el8+1646+e7d22cc1.x86_64 18/20 検証 : libslirp-4.4.0-1.module+el8+1646+e7d22cc1.x86_64 19/20 検証 : slirp4netns-1.2.0-2.module+el8+1646+e7d22cc1.x86_64 20/20 インストール済み: checkpolicy-2.9-1.el8.x86_64 container-selinux-2:2.205.0-2.module+el8+1646+e7d22cc1.noarch containerd.io-1.6.24-3.1.el8.x86_64 docker-buildx-plugin-0.11.2-1.el8.x86_64 docker-ce-3:24.0.6-1.el8.x86_64 docker-ce-cli-1:24.0.6-1.el8.x86_64 docker-ce-rootless-extras-24.0.6-1.el8.x86_64 docker-compose-plugin-2.21.0-1.el8.x86_64 fuse-common-3.3.0-16.el8.x86_64 fuse-overlayfs-1.11-1.module+el8+1646+e7d22cc1.x86_64 fuse3-3.3.0-16.el8.x86_64 fuse3-libs-3.3.0-16.el8.x86_64 libcgroup-0.41-19.el8.x86_64 libslirp-4.4.0-1.module+el8+1646+e7d22cc1.x86_64 policycoreutils-python-utils-2.9-19.el8.noarch python3-audit-3.0.7-2.el8.2.ML.1.x86_64 python3-libsemanage-2.9-8.el8.ML.1.x86_64 python3-policycoreutils-2.9-19.el8.noarch python3-setools-4.3.0-3.el8.x86_64 slirp4netns-1.2.0-2.module+el8+1646+e7d22cc1.x86_64 完了しました! [root@test244 ~]#
docker バージョン確認
実行コマンド
docker -v
実行ログ
[root@test244 ~]# docker -v Docker version 24.0.6, build ed223bc [root@test244 ~]#
docker の起動と自動起動設定
実行コマンド
systemctl status docker sudo systemctl enable docker sudo systemctl start docker systemctl status docker
実行ログ
[root@test244 ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: https://docs.docker.com [root@test244 ~]# [root@test244 ~]# sudo systemctl enable docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service. [root@test244 ~]# [root@test244 ~]# sudo systemctl start docker [root@test244 ~]# [root@test244 ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2023-10-02 20:25:39 EDT; 8s ago Docs: https://docs.docker.com Main PID: 3866 (dockerd) Tasks: 10 Memory: 53.5M CGroup: /system.slice/docker.service mq3866 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 10月 02 20:25:37 test244 systemd[1]: Starting Docker Application Container Engine... 10月 02 20:25:37 test244 dockerd[3866]: time="2023-10-02T20:25:37.201841779-04:00" level=info msg="Start> 10月 02 20:25:37 test244 dockerd[3866]: time="2023-10-02T20:25:37.303017012-04:00" level=info msg="Loadi> 10月 02 20:25:38 test244 dockerd[3866]: time="2023-10-02T20:25:38.904783892-04:00" level=info msg="Firew> 10月 02 20:25:39 test244 dockerd[3866]: time="2023-10-02T20:25:39.108602561-04:00" level=info msg="Loadi> 10月 02 20:25:39 test244 dockerd[3866]: time="2023-10-02T20:25:39.206540486-04:00" level=info msg="Docke> 10月 02 20:25:39 test244 dockerd[3866]: time="2023-10-02T20:25:39.207181187-04:00" level=info msg="Daemo> 10月 02 20:25:39 test244 dockerd[3866]: time="2023-10-02T20:25:39.281732859-04:00" level=info msg="API l> 10月 02 20:25:39 test244 systemd[1]: Started Docker Application Container Engine. [root@test244 ~]#
docker をユーザーで実行する場合
以下の設定を実施する。(今回は不要とした。)
sudo usermod -aG docker $USER sudo systemctl restart docker
docker-compose の設定
最新版のインストール
インストール
実行コマンド
curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi -
実行ログ
[root@test244 ~]# [root@test244 ~]# curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi - [root@test244 ~]#
権限設定
実行コマンド
sudo chmod +x docker-compose-linux-x86_64
実行ログ
[root@test244 ~]# [root@test244 ~]# sudo chmod +x docker-compose-linux-x86_64 [root@test244 ~]#
実行モジュールの移動
実行コマンド
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
実行ログ
[root@test244 ~]# [root@test244 ~]# sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose [root@test244 ~]#
バージョンを指定してインストール:今回は実行しておらず未検証
インストール
実行コマンド
sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-Linux-x86_64
この場合は /usr/local/bin/docker-compose
を指定してダウンロード先を指定している。
権限の変更
実行コマンド
sudo chmod +x /usr/local/bin/docker-compose
docker-compose のインストールバージョンの確認
実行コマンド
docker-compose version
実行ログ
[root@test244 ~]# docker-compose version Docker Compose version v2.22.0 [root@test244 ~]#