情况与问题
我正在尝试跟随本指南 https://medium.com/@notsinge/making-your-own-linuxkit-with-docker-for-mac-5c1234170fb1关于“如何使用 docker for mac 制作自己的 linuxkit”,您可以在其中添加一些通常不存在于 docker 镜像中的内核模块。
经过大量阅读和测试后,我未能完成最简单的(人们认为的)测试用例存储库 https://github.com/linuxkit/linuxkit:
linuxkit/test/cases/020_kernel/011_kmod_4.9.x/
https://github.com/linuxkit/linuxkit/tree/master/test/cases/020_kernel/011_kmod_4.9.x https://github.com/linuxkit/linuxkit/tree/master/test/cases/020_kernel/011_kmod_4.9.x
checking the container for the linux kernel-version and config:
... host$ docker run -it --rm -v /:/host -v $(pwd):/macos alpine:latest
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
bdf0201b3a05: Pull complete
Digest: sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913
Status: Downloaded newer image for alpine:latest
/ # / # uname -a
/bin/sh: /: Permission denied
/ #
/ #
/ # uname -a
Linux 029b8e5ada75 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 Linux
/ # cp /host/proc/config.gz /macos/
/ # exit
我回到了github历史 https://github.com/linuxkit/linuxkit/blob/98961e962c01e2eb16db3f948520913e0b739065/test/cases/020_kernel/011_kmod_4.9.x/Dockerfile找到我本地 linuxkit 内核版本的哈希值并修改该示例的 dockerfile(或者基本上使用旧的)。
到目前为止,一切都很好。问题是,如果我尝试做任何与内核模块相关的事情(modinfo
, modprobe
, depmod
, insmod
),我会得到这样的错误:
modinfo: can't open '/lib/modules/4.9.125-linuxkit/modules.dep': No such file or directory
这是因为该路径根本不存在于容器中(甚至没有模块文件夹)。如果我要检查——如上所述——就在alpine:latest
。所以那个 dockerfile 中似乎没有发生任何魔法。
Question
现在我完全困惑了,不知道该怎么做,因此我的问题......
如何从 linuxkit/linuxkit 执行 hello_world 示例?
补充笔记
linuxkit-repository 的文档没有提到任何有关该问题的信息:https://github.com/linuxkit/linuxkit/blob/master/docs/kernels.md#compiling-external-kernel-modules https://github.com/linuxkit/linuxkit/blob/master/docs/kernels.md#compiling-external-kernel-modules
-
为了方便测试我正在使用
docker-compose
# build with
# docker-compose build
version: '3'
services:
linux-builder:
image: my_linux_kit
build:
context: .
dockerfile: my_linux_kit.dockerfile
# args:
# buildno: 1
privileged: true
-
我什至欺骗它(通过手动插入)不显示任何错误,但也没有执行我认为代码应该执行的操作:
... host$: docker exec -it 7a33fad37914 sh
/ # ls
bin dev hello_world.ko lib mnt root sbin sys usr
check.sh etc home media proc run srv tmp var
/ # /bin/busybox insmod hello_world.ko
/ #