简体   繁体   English

如何使用 minikube 在 kubernetes 中使用本地图像

[英]how to use local images in kubernetes using minikube

I have just started working on k8s and I am doing some stuff locally,我刚刚开始在 k8s 上工作,我正在本地做一些事情,

I have a image created using docker desktop.我有一个使用 docker 桌面创建的图像。 Now, I want this image to be used within my minikube's VM environment.现在,我希望在 minikube 的 VM 环境中使用此映像。 I want to create a deployment using kubectl create deployment hello-minikube --image=my_local_image_name .我想使用kubectl create deployment hello-minikube --image=my_local_image_name创建一个部署。 Going through docs , and as per my understanding, it tells us how docker desktop can be used to interact with the minikube's in-built docker demon.通过docs ,根据我的理解,它告诉我们如何使用 docker desktop 与 minikube 的内置 docker 恶魔进行交互。 Following the instructions,按照指示,

Running docker images gives me images within minikube's docker.运行docker images给我minikube的泊坞窗内的图像。

But, in my case I want the other way around.但是,就我而言,我想要相反的方式。 How can I do that ?我怎样才能做到这一点 ?

Secondly, as a add-on how can I store images within minikube's VM's docker ?其次,作为附加组件,我如何在 minikube 的 VM 的 docker 中存储图像?

Docker Desktop and Docker from Minikube are two separate Docker Engines. Minikube 的 Docker Desktop 和 Docker 是两个独立的 Docker 引擎。 That is why they don't share the Docker image registry.这就是为什么他们不共享 Docker 镜像注册表的原因。

So you have the following options:因此,您有以下选择:

  1. Use Kubernetes from Docker Desktop instead of Minikube (Docker Desktop comes with Kubernetes cluster built-in).使用 Docker Desktop 中的 Kubernetes 而不是 Minikube(Docker Desktop 内置了 Kubernetes 集群)。

  2. Build your Docker image with Docker Engine from Minikube (instead of Docker Desktop).使用 Minikube 中的 Docker Engine(而不是 Docker Desktop)构建您的 Docker 镜像。

  3. Use external Docker registry (you can use Docker Hub or set up your own registry)使用外部 Docker 注册表(您可以使用 Docker Hub 或设置自己的注册表)

Running docker images gives me images within minikube's docker.运行 docker images 在 minikube 的 docker 中为我提供图像。

When you have this behaviour in your shell, rebuild your docker image.当您的 shell 中出现此行为时,请重建您的 docker 映像。

It will use Docker from Minikube and store your image into Minikube's Docker registry它将使用 Minikube 中的 Docker 并将您的图像存储到 Minikube 的 Docker 注册表中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM