`apt-get update` 在 Docker 构建中永远不会完成

发布于 2025-01-12 16:31:34 字数 1030 浏览 2 评论 0原文

我尝试构建的任何 Dockerfile(包括 apt-get update)都会无限期挂起。

我可以启动图像并在图像内运行 apt-get update ,没有任何问题。

docker run -it --entrypoint bash node:lts-bullseye
root@7b6ea3487aef:/# apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main arm64 Packages [120 kB]
Get:5 http://deb.debian.org/debian bullseye/main arm64 Packages [8070 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [2596 B]
Fetched 8392 kB in 2s (4936 kB/s)
Reading package lists... Done
root@7b6ea3487aef:/#

但如果是在 Docker 构建期间,它就会挂起!

更新-
我安装了 lima 并且我能够使用 -
很好地构建图像 lima nerdctl build .

所以我认为这一定是 Docker 相关的

Dockerfile 没什么特别的 - 这足以重现问题 -

FROM node:lts-buster-slim
RUN apt-get update

Any Dockerfile I try to build, that includes apt-get update, just hangs indefinitely.

I can launch an image and run apt-get update inside the image with no problems.

docker run -it --entrypoint bash node:lts-bullseye
root@7b6ea3487aef:/# apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main arm64 Packages [120 kB]
Get:5 http://deb.debian.org/debian bullseye/main arm64 Packages [8070 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [2596 B]
Fetched 8392 kB in 2s (4936 kB/s)
Reading package lists... Done
root@7b6ea3487aef:/#

But if it's during the Docker build, it just hangs!

Update -
I installed lima and I'm able to build the image fine with -
lima nerdctl build .

So I think this must be Docker related

Dockerfile is nothing special - this is enough to reproduce the issue -

FROM node:lts-buster-slim
RUN apt-get update

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

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

发布评论

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

评论(2

你是年少的欢喜 2025-01-19 16:31:34

“您好,您是否尝试过将其关闭并重新打开”?

我只需要重新启动 docker 守护进程。

"Hello, have you tried turning it off and on again"?

I just needed to restart the docker daemon.

纸短情长 2025-01-19 16:31:34

尝试重新启动 docker 和操作系统 - 不起作用(仍然太长 + apt-get install -y build-essential 失败 + pip install 失败),但添加构建网络作为主机解决了问题:

services:
  app:
    build:
      context: .
      network: host

或 docker build --network主机

来源:https://stackoverflow.com/a/66714888/11285211

Tried just restarting docker and os - not worked (still too long + apt-get install -y build-essential failed + pip install failed), but adding in build the network as host solved problem:

services:
  app:
    build:
      context: .
      network: host

or docker build --network host

Source: https://stackoverflow.com/a/66714888/11285211

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文