验证 Docker Buildx 构建实际上使用了本机的 Node。

huangapple go评论67阅读模式
英文:

Verify Docker Buildx build actually uses the native node

问题

如何验证Docker Buildx构建实际上使用了给定平台的本机节点?

我有一个基于QEMU的多平台Buildx构建器,名为maven,运行在x64 Linux上。我将Mac Mini附加为Arm构建的本机节点。

$ docker buildx ls
NAME/NODE  DRIVER/ENDPOINT             STATUS   BUILDKIT PLATFORMS
builder    docker-container                              
  builder0 unix:///var/run/docker.sock inactive          
maven *    docker-container                              
  maven0   unix:///var/run/docker.sock running  v0.11.0  linux/amd64*, linux/amd64/v2, linux/arm64, ....
  mac-mini ssh://some-user@10.1.2.3    running  v0.11.5  linux/arm64*, linux/amd64, linux/amd64/v2, ...

此外,我通过构建一个“Hello World”镜像来验证该设置是否有效。

$ docker buildx build --progress plain --builder maven --platform linux/arm64,linux/amd64 --tag my-hello-world .
...
#8 [linux/arm64 internal] load metadata for docker.io/library/debian:bullseye-slim
#8 DONE 1.0s

#6 [linux/amd64 internal] load metadata for docker.io/library/debian:bullseye-slim
#6 DONE 0.9s
...

问题是:Docker是否实际上使用了Arm构建的本机节点,还是仍然使用本地的QEMU“节点”?输出中没有明确说明。

英文:

How do I verify a Docker Buildx build actually uses the native node for a given platform?

I have a QEMU-base multi-platform Buildx builder called maven on x64 Linux. To that I appended a Mac Mini as native node for Arm builds.

$ docker buildx ls
NAME/NODE  DRIVER/ENDPOINT             STATUS   BUILDKIT PLATFORMS
builder    docker-container                              
  builder0 unix:///var/run/docker.sock inactive          
maven *    docker-container                              
  maven0   unix:///var/run/docker.sock running  v0.11.0  linux/amd64*, linux/amd64/v2, linux/arm64, ....
  mac-mini ssh://some-user@10.1.2.3    running  v0.11.5  linux/arm64*, linux/amd64, linux/amd64/v2, ...

Also, I verified the setup actually works by building a "Hello World" image.

$ docker buildx build --progress plain --builder maven --platform linux/arm64,linux/amd64 --tag my-hello-world .
...
#8 [linux/arm64 internal] load metadata for docker.io/library/debian:bullseye-slim
#8 DONE 1.0s

#6 [linux/amd64 internal] load metadata for docker.io/library/debian:bullseye-slim
#6 DONE 0.9s
...

The question is: did Docker actually use the native node for the Arm build or maybe still the local QEMU "node"? The output doesn't say.

答案1

得分: 0

Buildx driver docker-container 在每个节点上创建一个 moby/buildkit 容器。容器的名称是 buildx_buildkit_<node-name>。您可以查看该容器以了解它在做什么。

因此,无论是在“本地”主机还是在远程 Mac Mini 上执行以下操作:

  • $ docker ps 以验证容器名称,例如在我的情况下是 buildx_buildkit_mac-mini
  • $ docker exec -ti buildx_buildkit_mac-mini sh 以获取对正在运行的容器的控制台访问
  • 在容器内部运行 $ top 以监视进程

在这些容器内,PID 1 始终是 buildkitd。如果启动 Buildx 构建并且 Docker 分配工作给该节点,将启动其他进程。以下是示例。

空闲
验证 Docker Buildx 构建实际上使用了本机的 Node。

繁忙
验证 Docker Buildx 构建实际上使用了本机的 Node。

英文:

The Buildx driver docker-container creates a moby/buildkit container on each node. The name of the container is buildx_buildkit_<node-name>. You can poke around that container to understand what it's doing.

Hence, either on the "local" host or on the remote Mac Mini do

  • $ docker ps to verify what the container name is e.g. buildx_buildkit_mac-mini in my case
  • $ docker exec -ti buildx_buildkit_mac-mini sh to get console access to that running container
  • $ top inside the container to monitor processes

Inside those containers PID 1 is always buildkitd. Other process will be started if you start a Buildx build and Docker assigns work to this node. Examples below.

Idle
验证 Docker Buildx 构建实际上使用了本机的 Node。

Busy
验证 Docker Buildx 构建实际上使用了本机的 Node。

huangapple
  • 本文由 发表于 2023年4月6日 20:08:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定