Docker自定义.DEB文件位置

发布于 2025-02-13 04:36:42 字数 1639 浏览 1 评论 0原文

我必须编译自定义内核才能让Ubuntu在笔记本电脑上运行,现在我试图在上面运行Docker容器。

它生成了我安装的软件包:

  • Linux-Headers-5.15.30-25.25custom_5.15.15.30-25.25custom-1_amd64.deb
  • linux-image-5.15.15.30-25.330-25.25custom-dbg_5.15.15.30-25.30-25.25.25.25custom-1_amd64.deb
  • linux-image-5.15.30-25.25custom_5.15.15.330-25.255.25custom-1_amd64.deb

现在,当我尝试创建docker images时,我会收到以下错误:

...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-headers-5.15.30-25.25custom
E: Couldn't find any package by glob 'linux-headers-5.15.30-25.25custom'
E: Couldn't find any package by regex 'linux-headers-5.15.30-25.25custom'

dockerfile只是拔下nvidia映像,并添加其他一些包装,并

FROM nvidia/cuda:11.4.2-devel-ubuntu18.04

ARG COMPILE_GRAPHICS=OFF
ARG DEBIAN_FRONTEND=noninteractive

USER root

RUN  \
    set -ex && \
    apt-key update && \
    apt-get update && \
    apt-get install -y -q \
        build-essential \
        software-properties-common \
        openssl \
        curl && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /var/cache/apt/archives/ && \
    rm -rf /usr/share/doc/ && \
    rm -rf /usr/share/man/

...

添加了 一些其他包裹主机PC

~$ sudo dpkg -l | grep  linux-headers-5.15.30-25.2
ii  linux-headers-5.15.30-25.25custom          5.15.30-25.25custom-1                           amd64        Linux kernel headers for 5.15.30-25.25custom on amd64

使用上游Ubuntu内核软件包在其他机器上没有问题。

因此,猜猜Docker需要实际的软件包。如何添加自定义位置以获取软件包?

谢谢

I had to compile a custom kernel to get Ubuntu to run on my laptop and now I'm trying to run docker containers on it.

It generated packages I installed:

  • linux-headers-5.15.30-25.25custom_5.15.30-25.25custom-1_amd64.deb
  • linux-image-5.15.30-25.25custom-dbg_5.15.30-25.25custom-1_amd64.deb
  • linux-image-5.15.30-25.25custom_5.15.30-25.25custom-1_amd64.deb

Now when I try to create docker images I get the following error:

...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-headers-5.15.30-25.25custom
E: Couldn't find any package by glob 'linux-headers-5.15.30-25.25custom'
E: Couldn't find any package by regex 'linux-headers-5.15.30-25.25custom'

The Dockerfile just pulls an nvidia image and adds some other packages required

FROM nvidia/cuda:11.4.2-devel-ubuntu18.04

ARG COMPILE_GRAPHICS=OFF
ARG DEBIAN_FRONTEND=noninteractive

USER root

RUN  \
    set -ex && \
    apt-key update && \
    apt-get update && \
    apt-get install -y -q \
        build-essential \
        software-properties-common \
        openssl \
        curl && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /var/cache/apt/archives/ && \
    rm -rf /usr/share/doc/ && \
    rm -rf /usr/share/man/

...

It is installed on the host PC

~$ sudo dpkg -l | grep  linux-headers-5.15.30-25.2
ii  linux-headers-5.15.30-25.25custom          5.15.30-25.25custom-1                           amd64        Linux kernel headers for 5.15.30-25.25custom on amd64

There's no problem on other machines using the upstream Ubuntu kernel packages.

So guess docker needs the actual package. How can I add a custom location to fetch the packages?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素年丶 2025-02-20 04:36:44

我感觉到您正在混合容器内外的东西。

外部 - 在主机操作系统上,您必须编译自定义内核才能使Linux运行。到目前为止,一切都很好。

现在,您正在尝试构建一个Docker容器。因此,下一步正在容器内部发生。 Docker是轻巧的虚拟化,因此该容器与主机在同一内核上运行。由于某些软件包依赖关系是在内核的标题上,因此APT试图为它们安装Debian软件包,但找不到它们。当您运行自定义内核时,似乎很明显,并且该软件包在没有众所周知的存储库中。

为了摆脱这种情况:

  • 检查内核的标题是否可用,因为.deb
  • 使该容器内有.deb可用。将它们放入 docker构建上下文时,可能会发生这种情况。
  • 在安装.deb的任何需求之前,请确保您的Dockerfile安装.deb。这将阻止在线存储库中搜索它。

I get the feeling you are mixing up what is outside and inside of a container.

Outside - on your host operating system you had to compile a custom kernel to get Linux running. So far so good.

Now you are trying to build a docker container. So the next steps are happening inside the container. Docker is lightweight virtualization therefore the container runs on the same kernel as the host. Since some package dependency is on the kernel's headers, and apt is trying to install the Debian package for them but cannot find them. Seems obvious as you are running a custom kernel and the package is in none well-known repository.

To get out of the situation:

  • check whether the headers for your kernel are available as .deb
  • make that .deb available inside the container. This may happen by placing them into the Docker build context.
  • ensure your Dockerfile installs the .deb before installing whatever needs that .deb. This will prevent it is searched in online repositories.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文