0

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'
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).
    – larsks
    Jun 17 at 15:23

1 Answer 1

0

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. 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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.