`apt-get update` 在 Docker 构建中永远不会完成
我尝试构建的任何 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“您好,您是否尝试过将其关闭并重新打开”?
我只需要重新启动 docker 守护进程。
"Hello, have you tried turning it off and on again"?
I just needed to restart the docker daemon.
尝试重新启动 docker 和操作系统 - 不起作用(仍然太长 + apt-get install -y build-essential 失败 + pip install 失败),但添加构建网络作为主机解决了问题:
或 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:
or
docker build --network host
Source: https://stackoverflow.com/a/66714888/11285211