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"로 태그됨)

관련 정보