Answers: <p>As the <a href="https://github.com/kubernetes/minikube/blob/0c616a6b42b28a1aab8397f5a9061f8ebbd9f3d9/README.md#reusing-the-docker-daemon" rel="nofollow noreferrer">README</a> describes, you can reuse the Docker daemon from Minikube with <code>eval $(minikube docker-env)</code>.</p>
  <p>So to use an image without uploading it, you can follow these steps:</p>
  <ol>
  <li>Set the environment variables with <code>eval $(minikube docker-env)</code></li>
  <li>Build the image with the Docker daemon of Minikube (eg <code>docker build -t my-image .</code>)</li>
  <li>Set the image in the pod spec like the build tag (eg <code>my-image</code>)</li>
  <li>Set the <a href="https://kubernetes.io/docs/concepts/containers/images/#updating-images" rel="nofollow noreferrer"><code>imagePullPolicy</code></a> to <code>Never</code>, otherwise Kubernetes will try to download the image.</li>
  </ol>
  <p><strong>Important note:</strong> You have to run <code>eval $(minikube docker-env)</code> on each terminal you want to use, since it only sets the environment variables for the current shell session.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-06-22T09:08:06.270Z
Answers: 2022-06-22T09:08:06.270Z
Answers: Juan Fontes
Body: <p>I have a k8s pod that is running docker. My issue is that for the docker images on my host machine to be available within the pod I either have to run the image as a pod or run a docker pull script at the beginning of my deployment.</p>
  <p>Docker's pull API rate limits after some time and these images are not meant to be run without inputs, so I would like to know if there's another way to either expose the host's docker or get access to those images.</p>
  <p>I am currently trying to expose the local docker socket, but that does not appear to be provide access to the Deployment from the local docker instance. I'm testing by running <code>docker images</code> inside the Deployment and on the host to see if the images match which they don't.</p>
  <pre><code>volumeMounts:
      - mountPath: /var/run/docker.sock:ro
        name: docker-sock
  ...
  volumes:
      - name: docker-sock
      hostPath:
          path: /var/run/docker.sock
  </code></pre>
  <p>I'm also mounting with minikube like so</p>
  <pre><code>minikube start --memory='5000MB' --mount --mount-string='/:/k8s' --cpus='4'
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2022-06-17T15:23:57.100Z
Comments: You could run a registry on k3s, and explicitly push those images into the internal registry (and then access them from there rather than using the upstream reference).
Comments: larsks
Tags: <docker><kubernetes>
Title: How can I make host docker images available to k8s Deployment?
UserDisplayName: Nat
ThreadText: # How can I make host docker images available to k8s Deployment?
  
  (Asked by: username_0 on 2022-06-15)
  
  I have a k8s pod that is running docker. My issue is that for the docker images on my host machine to be available within the pod I either have to run the image as a pod or run a docker pull script at the beginning of my deployment.
  
  Docker's pull API rate limits after some time and these images are not meant to be run without inputs, so I would like to know if there's another way to either expose the host's docker or get access to those images.
  
  I am currently trying to expose the local docker socket, but that does not appear to be provide access to the Deployment from the local docker instance. I'm testing by running `docker images` inside the Deployment and on the host to see if the images match which they don't.
  
  ```
  volumeMounts:
      - mountPath: /var/run/docker.sock:ro
        name: docker-sock
  ...
  volumes:
      - name: docker-sock
      hostPath:
          path: /var/run/docker.sock
  
  ```
  
  I'm also mounting with minikube like so
  
  ```
  minikube start --memory='5000MB' --mount --mount-string='/:/k8s' --cpus='4'
  
  ```
  
  **Tags:** docker, kubernetes
  
  > **Comments:**
  > **username_1**: You could run a registry on k3s, and explicitly push those images into the internal registry (and then access them from there rather than using the upstream reference).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-06-22. Score: 1 | Accepted answer
  
  As the [README](https://github.com/kubernetes/minikube/blob/0c616a6b42b28a1aab8397f5a9061f8ebbd9f3d9/README.md#reusing-the-docker-daemon) 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. 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`](https://kubernetes.io/docs/concepts/containers/images/#updating-images) to `Never`, otherwise Kubernetes will try to download the image.
  
  **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.
  
  
  ---
  
  