如何在K8S MasterNode中获取所有Docker图像层

发布于 2025-01-28 19:21:11 字数 603 浏览 5 评论 0原文

我是Kubernetes和Docker的初学者。

我想接收在K8的主节点上运行的所有容器的图像层。 (如果有任何方式,它可能是一个容器的一层。)

我对此的考虑的方式是

  1. 通过kubectl exec -it命令输入容器,并接收图像层 但是我失败了,因为我不知道容器中是否有图像层的信息。

  2. 从主节点访问工人节点,并仅通过docker Inspect命令过滤出图层 但是我找不到一种方法来使工人节点执行命令。 另外,我找不到一种访问工人节点的方法。

这是我的开发环境:

“

我创建了三个虚拟机,从vm vitualbox,一个主节点和两个工作的工作节点,两个工具节点( OS是Ubuntu 20.04。

最终目标是获得所有运行容器的图像层。

无论如何,可以拥有一个容器,因此我想从运行主节点的终端输出图像层或包括图像层的信息(来自Docker Inspect命令的信息)输出。

对于任何措辞,我深表歉意,这是使用翻译人员发布的。

I'm a beginner at Kubernetes and Docker.

I want to receive the image layer of all the containers that are operating on the master node of k8s. (If there is any way, it may be a layer of one container.)

The way I thought about it so far is

  1. Enter the container through the kubectl exec -it command and receive the image layer
    But I failed because I didn't know if there was information of the image layer in the container.

  2. Access the worker node from the master node and filter out only the image layer through the docker inspect command
    But I couldn't find a way to get the worker node to execute the command.
    Also, I could not find a way to access the worker node.

Here is my development environment:

screenshot of VMs

I created three virtual machines from vm vitualbox, one master node and two worker nodes, and the OS is Ubuntu 20.04.

The final goal is to obtain an image layer of all running containers.

Anyway, it is okay to have one container, so I want to have the image layer output from the terminal running the master node or the information including the image layer (information from the docker inspect command) output.

My apologies for any phrasing, this was posted using a translator.

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

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

发布评论

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

评论(1

吖咩 2025-02-04 19:21:11

不确切地知道您是否确实是指“图层”或“图像名称或ID”,但是,此命令将输出吊舱的名称,他们的图像名称和他们的Docker Pullable ID :(

kubectl get pods  -o=custom-columns=NAME:".metadata.name",IMAGE:".spec.containers[*].image",IMAGE_ID:".status.containerStatuses[*].
imageID"

如果这对您来说效果很好,您可以在此处查看更多示例:在kubernetes部署的豆荚中获取图像和sha图像ID ),

因为一旦您可以直接在Kubernetes中检查图像层,一旦您可以直接拉动此图像使用Docker Binary检查他们的图层:(

docker history IMAGE_NAME:IMAGE_TAG

cf there https://howchoo.com/docker/how-to-show-all-layers-of-a-docker-image

更新:
或者,您可以JUSE使用kubectl获取pod -o wide获取当前运行POD的图像

Don't know exactly if you actually mean "layer" or "image name or ID", however, this command will output you the name of the pods, their image name and their docker pullable ID:

kubectl get pods  -o=custom-columns=NAME:".metadata.name",IMAGE:".spec.containers[*].image",IMAGE_ID:".status.containerStatuses[*].
imageID"

(If this doesnt work well for you, You can check here for more examples: Get the image and SHA image ID of images in pod on Kubernetes deployment)

Since there is no way to inspect images layers in kubernetes directly, once you have pulled this images, you can check their layers with docker binary:

docker history IMAGE_NAME:IMAGE_TAG

(cf here https://howchoo.com/docker/how-to-show-all-layers-of-a-docker-image)

UPDATE:
or you can juste use kubectl get pod -o wide to get the images of the current running pods

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