Is there an equivalent to "minikube docker-env" for using Docker in K8s?

1/5/2020

I've successfully used this to build an image in the Docker instance inside Minikube:

eval $(minikube docker-env)
docker build . -t image:tag

So the image is built and pushed directly into Minikube/Docker. I now want to test my image in K8s so I've built a small test cluster on some Centos VMs (one master and two workers). I'd prefer to not use Docker Hub for this test to store the image for subsequent pulling from my cluster (issue of company IP). It would be great if there was some way to use the same environment variables as set by the minikube command to push the image directory to the master node:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.64.3:2376"
export DOCKER_CERT_PATH="/Users/username/.minikube/certs"

I'm guessing the second variable above could be amended to the network address of the K8s master node which includes Docker. If I set DOCKER_TLS_VERIFY to "0", does that means it won't need the cert path defined in the third?

Thanks in advance!

-- ShawnC
docker
kubernetes

1 Answer

1/5/2020

I think you have a couple of notions mixed up. In order to use a docker image in kubernetes, you need to have it on the node where the pod is deployed. Minikube is both the master and the node, that's why it's working. What you would need to do in your setup is building the image for every worker node, not the master.

What would work better in my opinion is setting up your own docker registry to push images to, which shouldn't take long (check out this helm chart: https://github.com/helm/charts/tree/master/stable/docker-registry . If you're not familiar with helm take a look into it, it's an easy way to install applications in kubernetes )

-- Radu Mazilu
Source: StackOverflow