buildrootを使用してRPiでコンテナを実行する:CNI関連の問題

buildrootを使用してRPiでコンテナを実行する:CNI関連の問題

現在、RPi(CM4モジュール)でコンテナを実行するためにbuildrootを使用しようとしています。

コンテナを実行できるようにカーネルとアドインパッケージを設定しました。containerd端末で実行して、正しく実行されていることを確認できます。同時に、次の操作を実行できます。

ctr run --no-pivot --rm docker.io/library/hello-world:latest test

これがうまくいき、hello-worldメッセージを受け取ります。

しかし、より野心的なコンテナを実行するとエラーが発生します。

ctr run --no-pivot --rm -t --net-host docker.io/library/nginx:1.21 nginx

出力:

/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: 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/01/23 11:09:36 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2023/01/23 11:09:36 [notice] 1#1: try again to bind() after 500ms
2023/01/23 11:09:36 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2023/01/23 11:09:36 [notice] 1#1: try again to bind() after 500ms
2023/01/23 11:09:36 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
2023/01/23 11:09:36 [notice] 1#1: try again to bind() after 500ms

これは、ポート 80 で実行される他のサービスによるものです。サービスを停止すると機能します。

/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: 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/01/23 12:42:51 [notice] 1#1: using the "epoll" event method
2023/01/23 12:42:51 [notice] 1#1: nginx/1.21.6
2023/01/23 12:42:51 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2023/01/23 12:42:51 [notice] 1#1: OS: Linux 5.10.110-v8
2023/01/23 12:42:51 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1024:1024
2023/01/23 12:42:51 [notice] 1#1: start worker processes
2023/01/23 12:42:51 [notice] 1#1: start worker process 31
2023/01/23 12:42:51 [notice] 1#1: start worker process 32
2023/01/23 12:42:51 [notice] 1#1: start worker process 33
2023/01/23 12:42:51 [notice] 1#1: start worker process 34

しかし、問題はまだポート80をオフにする必要があるということです。

それでは、そのポートを別の場所にマッピングしたいと思います(たとえば、ポート8080)。

これを試してみましたがnerdctl(以前はビルドルームコンパイルを使用して設定したことがありました)、次のエラーが発生しました。

# nerdctl run --rm -it --name nginx -p 80:8080 docker.io/library/nginx:1.21
FATA[0001] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2023-01-23T13:45:04+01:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): running [/usr/sbin/iptables -t nat -A CNI-40513ffc80d158b3c3937c5b -d 10.4.0.18/24 -j ACCEPT -m comment --comment name: \"bridge\" id: \"default-9c651b466d3604dfe46ace174f0cb61634ab731d560428d10475b357016d79e3\" --wait]: exit status 1: Warning: Extension comment revision 0 not supported, missing kernel module?\niptables: No chain/target/match by that name.\n"
Failed to write to log, write /var/lib/nerdctl/1935db59/containers/default/9c651b466d3604dfe46ace174f0cb61634ab731d560428d10475b357016d79e3/oci-hook.createRuntime.log: file already closed: unknown 

これを実現するには、CNIプラグインを有効にする必要があるだけではありません。host-localが見つからないため、以下をダウンロード/opt/cni/bin/しました。https://github.com/containerd/containerd/releases/download/v1.6.15/cri-containerd-cni-1.6.15-linux-arm64.tar.gz、そして抽出/opt/cni/bin/host-localも可能です/etc/cni/net.d/10-containerd-net.conflist。どちらもbuildrootパッケージでは使用できません。それにもかかわらず、設定を調整しようとしても/etc/cni/net.d/10-containerd-net.conflistまだ機能しません。ビルドルートにコンパイルするCNIモジュールはもうありません。

これが私が付いているところです。

私がここで何を見逃しているのでしょうか?iptablesまた、buildrootでも有効になるので問題になりません。

私の目標は、buidrootで作成された環境でRPi CM4でコンテナを実行して、ポートなどを自由にマッピングできるようにすることです。

ctrorを使用してポートをマッピングできないことがわかっているので、runc次のように試しましたnerdctl(主にbuildrootでモジュールとして使用できるため)。

(汎用コンテナタグが利用できないため、「docker」とタグ付けされています)

ベストアンサー1

おすすめ記事