<p>I created customize Docker Image and stored in my local system Now I want use that Docker Image via kubectl .</p>
<p>Docker image:-
1:- docker build -t backend:v1 .</p>
<p>Then Kubernetes file:-</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: backend
  namespace: web-console
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: backend
    spec:
      containers:
      - env:
        - name: mail_auth_pass
        - name: mail_auth_user
        - name: mail_from
        - name: mail_greeting
        - name: mail_service
        - name: mail_sign
        - name: mongodb_url
          value: mongodb://mongodb.mongodb.svc.cluster.local/console
        - name: server_host
          value: &quot;0.0.0.0&quot;
        - name: server_port
          value: &quot;3000&quot;
        - name: server_sessionSecret
          value: &quot;1234&quot;
          image: backend
          imagePullPolicy: Never
        name: backend
        resources: {}
      restartPolicy: Always
status: {}
</code></pre>
<p>Command to run kubectl:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl create -f  backend-deployment.yaml
</code></pre>
<p>Getting the error:</p>
<pre><code>error: error validating &quot;backend-deployment.yaml&quot;: error validating data: [ValidationError(Deployment.spec.template.spec.containers[0].env[9]): unknown field &quot;image&quot; in io.k8s.api.core.v1.EnvVar, ValidationError(Deployment.spec.template.spec.containers[0].env[9]): unknown field &quot;imagePullPolicy&quot; in io.k8s.api.core.v1.EnvVar]; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

gaurav agnihotri
<h2>Local Registry</h2>
<p>Set the local registry first using this command</p>
<p><code>docker run -d -p 5000:5000 --restart=always --name registry registry:2</code></p>
<h2>Image Tag</h2>
<p>Given a <code>Dockerfile</code>, the image could be built and tagged this easy way:</p>
<p><code>docker build . -t localhost:5000/my-image</code></p>
<p>Push the image on the local repo:</p>
<p><code>docker push localhost:5000/my-image</code></p>
<h2>Using the image</h2>
<p>The pushed image can now be used:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  labels:
    app: my-app
spec:
  containers:
    - name: app
      image: localhost:5000/my-image
      imagePullPolicy: IfNotPresent
</code></pre>
<h2>Deploy Pod</h2>
<p>The pod can be deployed using:</p>
<p><code>kubectl create -f pod.yml</code></p>
<p>Hope this comes in handy :)</p>
