はじめに
buildahでビルドしたイメージをcri-oのローカルレジストリに追加、参照できるようにするためにハマったので記載する。
問題
次のように作成したDockerfileをcri-oから参照しようとすると確認ができなかった。
$ cat >> Dockerfile < EOF FROM 'docker.io/nginx:latest' RUN apt-get update && apt-get install -y iputils-ping CMD ["nginx", "-g", "daemon off;"] EOF $ buildah bud -t test/nginx -f Dockerfile $ buildah images|grep nginx buildah bud -t test/nginx -f ./Dockerfile buildah images localhost/test/nginx latest 7111de1b2dd9 18 seconds ago 213 MB $ sudo crictl images|grep nginx (表示されない)
原因、理由
cri-oがデーモンで動作していることに対し、buildahはデーモンで動作していない。 また、buildahはユーザごとに異なるローカルレジストリを持つ。
- ルートユーザーの場合:/var/lib/containers/storage
- 非ルートユーザーの場合:$HOME/.local/share/containers/storage
今回、cri-oとルートユーザのローカルレジストリが共通であったため、非ルートユーザでビルドしたイメージをcri-oから確認ができなかった。 そのため、sudoコマンドを使用してビルドする。
$ sudo buildah bud -t test/nginx -f Dockerfile #確認 $ sudo buildah images|grep nginx localhost/test/nginx latest 7111de1b2dd9 18 seconds ago 213 MB $ sudo crictl images|grep nginx localhost/test/nginx latest 7111de1b2dd91 213MB
無事に、cri-oからビルドしたイメージを確認するができた。