2

情况和问题

我正在尝试按照本指南“如何使用 docker for mac 制作自己的 linuxkit”,您可以在其中添加一些通常不存在于 docker 映像中的内核模块。

经过大量阅读和测试后,我未能在存储库中执行最简单(人们会认为)的测试用例:

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


检查容器的 linux 内核版本和配置:
... 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 历史中找到我本地 linuxkit 内核版本的哈希并修改了该示例的 dockerfile(或基本上使用旧的)。

到目前为止,一切都很好。问题是,如果我尝试做任何与内核模块(、、、、modinfo)相关的事情modprobe,我会得到如下错误:depmodinsmod

modinfo: can't open '/lib/modules/4.9.125-linuxkit/modules.dep': No such file or directory

这是因为容器中根本不存在该路径(甚至没有模块文件夹)。如果我要检查 - 如上所述 - 只是在alpine:latest. 因此,该 dockerfile 中似乎没有发生任何魔法。

问题

现在我完全感到困惑并束手无策,因此我的问题......

如何从 linuxkit/linuxkit 执行 hello_world 示例?

补充说明

  • linuxkit-repository 的文档没有提到这个问题: 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 
    / # 
    
4

0 回答 0