拉一个本地图像在库伯纳斯运行一个荚 [英] Pull a local image to run a pod in Kubernetes

查看:140
本文介绍了拉一个本地图像在库伯纳斯运行一个荚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Dockerfile创建的以下图像:

I have the following image created by a Dockerfile:

REPOSITORY TAG IMAGE ID CREATED SIZE

REPOSITORY TAG IMAGE ID CREATED SIZE

ruby / lab latest f1903b1508cb 2小时前729.6 MB

ruby/lab latest f1903b1508cb 2 hours ago 729.6 MB

我有以下YML文件:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ruby-deployment
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: ruby
    spec:
      containers:
      - name: ruby-app
        image: ruby/lab
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 4567

当我创建部署时,我在pod中得到以下信息:

When I create the deployment I got the following info in the pods:

ruby-deployment-3830038651-sa4ii   0/1       ImagePullBackOff   0          7m
ruby-deployment-3830038651-u1tvc   0/1       ImagePullBackOff   0          7m

And:

 8m            2m              6       {kubelet minikube}      spec.containers{ruby}   Normal          Pulling         pulling image "ruby/lab:latest"
  8m            2m              6       {kubelet minikube}      spec.containers{ruby}   Warning         Failed          Failed to pull image "ruby/lab:latest": Error: image ruby/lab not found
  8m            2m              6       {kubelet minikube}                              Warning         FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "ruby" with ErrImagePull: "Error: image ruby/lab not found"

真的有必要在Docker中注册这个?我只想在本地进行测试,并通过我的代码/回购给朋友进行测试目的

Is really necessary to have registry in docker for this? I just want to make test locally and pass my code/repo to a friend for testing purposes

谢谢

推荐答案

您可以通过运行

eval $(minikube docker-env)

然后,您可以正常构建图像,并通过kubectl正常创建您的kubernetes资源。确保您有

Then you can build your image normally and create your kubernetes resources normally using kubectl. Make sure that you have

imagePullPolicy: IfNotPresent

您的YAML或JSON规范中的

in your YAML or JSON specs.

此外,您可以有一个标志将不安全的注册表传递到minikube VM。但是,这必须在您第一次创建机器时指定。

Additionally, you can there is a flag to pass in insecure registries into the minikube VM. However, this must be specified the first time you create the machine.

minikube start --insecure-registry

您可能还想在使用私人注册表时阅读此文件
http://kubernetes.io/docs/user-guide/images/

You may also want to read this when using a private registry http://kubernetes.io/docs/user-guide/images/

这篇关于拉一个本地图像在库伯纳斯运行一个荚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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