俺#

新潟市でIT業を営むおっさんのブログ。

#centos8 に #docker ce をインストール。#yum( #dnf )でパッケージバージョン指定

docs.docker.com

現時点で公式手順に従ってCentOS 8にDocker Engine Communityをインストールしようとすると以下のエラーが出る。

[root@fuga yamagw]# dnf*1
install docker-ce docker-ce-cli containerd.io
エラー:
問題: package docker-ce-3:19.03.4-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
- cannot install the best update candidate for package docker-ce-3:18.09.0-3.el7.x86_64
- package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.el7.x86_64 is excluded
- package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

「containerd.ioの1.2.2以降が見つからん」とおっしゃる。この対処として「素直に--nobestを指定する」「containerd.ioのrpmを拾ってくる」のいずれでも動くことは動くが、微妙に気持ち悪い。なので「少し前のバージョンのDockerを使う」を試してみる。

まず使用できるパッケージのリストを確認。「yum list --showduplicates」すると過去分も含めてリストしてくれる。

[root@fuga yamagw]# dnf list --showduplicates containerd.io
containerd.io.x86_64 1.2.0-1.2.beta.2.el7 docker-ce-stable
(略)
containerd.io.x86_64 1.2.0-3.el7 docker-ce-stable

最新のcontainerd.ioは1.2.0のようだ。

[root@fuga yamagw]# dnf list --showduplicates docker-ce
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
(略)
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
(略)
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
(略)
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable

docker-ceとdocker-ce-cliについても確認し、両方に共通して存在するバージョンを新しい方から順にさかのぼって試していくと、「18.09.1-3.el7」であればcontainerd.io 1.2.0と組み合わせられることが判った。

[root@fuga yamagw]# dnf install docker-ce-18.09.1-3.el7 docker-ce-cli-18.09.1-3.el7 containerd.io
依存関係が解決しました。
========================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリ サイズ
========================================================================================================================
Installing:
containerd.io x86_64 1.2.0-3.el7 docker-ce-stable 22 M
docker-ce x86_64 3:18.09.1-3.el7 docker-ce-stable 19 M
docker-ce-cli x86_64 1:18.09.1-3.el7 docker-ce-stable 14 M

トランザクションの概要
========================================================================================================================
インストール 3 パッケージ
これでよろしいですか? [y/N]:

よろしいです。インストール後に「docker run hello-world」で確認。

[root@fuga yamagw]# systemctl restart docker
[root@fuga yamagw]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
(略)

問題ないようですな。さて、このままだと「yum update」する度にエラーが出てしまうので、「docker-ce」と「docker-ce-cli」をupdate対象から除外する設定を行う。

[root@fuga yamagw]# emacs /etc/yum.conf

exclude=docker-ce*

(末尾に追記)

「ん?もしかしてdnf.conf?」と思ったが「yum.conf」は「dnf.conf」のシンボリックリンクになってました。

[root@fuga ~]# ls -al /etc/yum.conf
lrwxrwxrwx. 1 root root 12 5月 14 04:34 /etc/yum.conf -> dnf/dnf.conf

除外したことを忘れないようにしないと延々と古いものを使い続けることになる点は要注意ですな。

*1:CentOS8から「yum」は「dnf」になった。使用方法は基本的には同じで「yum」もまだ使える。