如何在 Minikube 中使用本地 docker 镜像? [英] How to use local docker images with Minikube?

查看:95
本文介绍了如何在 Minikube 中使用本地 docker 镜像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个 docker 镜像要与 minikube 一起使用.我不想先上传然后下载相同的图像,而不是直接使用本地图像.我该怎么做?

I have several docker images that I want to use with minikube. I don't want to first have to upload and then download the same image instead of just using the local image directly. How do I do this?

我尝试过的东西:
1.我尝试运行这些命令(分别删除 minikube 的实例并重新开始)

Stuff I tried:
1. I tried running these commands (separately, deleting the instances of minikube both times and starting fresh)

kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989
kubectl run hdfs --image=fluxcapacitor/hdfs:latest --port=8989 imagePullPolicy=Never

输出:

NAME                    READY     STATUS              RESTARTS   AGE
hdfs-2425930030-q0sdl   0/1       ContainerCreating   0          10m

它只是停留在某个状态,但永远不会达到就绪状态.

It just gets stuck on some status but never reaches the ready state.


2.我尝试创建一个注册表,然后将图像放入其中,但这也不起作用.我可能做错了,但我找不到执行此任务的正确说明.


2. I tried creating a registry and then putting images into it but that didn't work either. I might've done that incorrectly but I can't find proper instructions to do this task.

请提供在本地 kubernetes 实例中使用本地 docker 镜像的说明.
操作系统:ubuntu 16.04
Docker:Docker 版本 1.13.1,构建 092cba3
Kubernetes:

Please provide instructions to use local docker images in local kubernetes instance.
OS: ubuntu 16.04
Docker : Docker version 1.13.1, build 092cba3
Kubernetes :

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.1", Compiler:"gc", Platform:"linux/amd64"}

如果有人能帮我找到一个使用 docker-compose 的解决方案,那就太棒了.

If someone could help me get a solution that uses docker-compose to do this, that'd be awesome.

eval $(minikube docker-env:

REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE
fluxcapacitor/jupyterhub                              latest              e5175fb26522        4 weeks ago         9.59 GB
fluxcapacitor/zeppelin                                latest              fe4bc823e57d        4 weeks ago         4.12 GB
fluxcapacitor/prediction-pmml                         latest              cae5b2d9835b        4 weeks ago         973 MB
fluxcapacitor/scheduler-airflow                       latest              95adfd56f656        4 weeks ago         8.89 GB
fluxcapacitor/loadtest                                latest              6a777ab6167c        5 weeks ago         899 MB
fluxcapacitor/hdfs                                    latest              00fa0ed0064b        6 weeks ago         1.16 GB
fluxcapacitor/sql-mysql                               latest              804137671a8c        7 weeks ago         679 MB
fluxcapacitor/metastore-1.2.1                         latest              ea7ce8c5048f        7 weeks ago         1.35 GB
fluxcapacitor/cassandra                               latest              3cb5ff117283        7 weeks ago         953 MB
fluxcapacitor/apachespark-worker-2.0.1                latest              14ee3e4e337c        7 weeks ago         3.74 GB
fluxcapacitor/apachespark-master-2.0.1                latest              fe60b42d54e5        7 weeks ago         3.72 GB
fluxcapacitor/package-java-openjdk-1.8                latest              1db08965289d        7 weeks ago         841 MB
gcr.io/google_containers/kubernetes-dashboard-amd64   v1.5.1              1180413103fd        7 weeks ago         104 MB
fluxcapacitor/stream-kafka-0.10                       latest              f67750239f4d        2 months ago        1.14 GB
fluxcapacitor/pipeline                                latest              f6afd6c5745b        2 months ago        11.2 GB
gcr.io/google-containers/kube-addon-manager           v6.1                59e1315aa5ff        3 months ago        59.4 MB
gcr.io/google_containers/kubedns-amd64                1.9                 26cf1ed9b144        3 months ago        47 MB
gcr.io/google_containers/kube-dnsmasq-amd64           1.4                 3ec65756a89b        5 months ago        5.13 MB
gcr.io/google_containers/exechealthz-amd64            1.2                 93a43bfb39bf        5 months ago        8.37 MB
gcr.io/google_containers/pause-amd64           

推荐答案

作为 README 描述,您可以使用 eval $(minikube docker-env) 重用 Minikube 中的 Docker 守护程序.

As the README describes, you can reuse the Docker daemon from Minikube with eval $(minikube docker-env).

因此要在不上传图片的情况下使用图片,您可以按照以下步骤操作:

So to use an image without uploading it, you can follow these steps:

  1. 使用 eval $(minikube docker-env)
  2. 设置环境变量
  3. 使用 Minikube 的 Docker 守护进程构建镜像(例如 docker build -t my-image .)
  4. 在 pod 规范中像构建标签一样设置图像(例如 my-image)
  5. imagePullPolicy 设置为Never,否则 Kubernetes 会尝试下载镜像.
  1. Set the environment variables with eval $(minikube docker-env)
  2. Build the image with the Docker daemon of Minikube (eg docker build -t my-image .)
  3. Set the image in the pod spec like the build tag (eg my-image)
  4. Set the imagePullPolicy to Never, otherwise Kubernetes will try to download the image.

重要提示:您必须在要使用的每个终端上运行 eval $(minikube docker-env),因为它只为当前设置环境变量外壳会话.

Important note: You have to run eval $(minikube docker-env) on each terminal you want to use, since it only sets the environment variables for the current shell session.

这篇关于如何在 Minikube 中使用本地 docker 镜像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆