Kubernetes fails to run a docker image build locally

The image you created in the docker won't be available in the Minikube because Minikube have it's own docker daemon and it checks for the docker images there and DockerHub.

Follow the below steps to access the Minikube Docker daemon, build and deploy the docker image:

  1. use the minikube docker-env command that outputs environment variables needed to point the local Docker daemon to the minikube internal Docker registry.

minikube docker-env export DOCKER_TLS_VERIFY=”1" export DOCKER_HOST=”tcp://172.17.0.2:2376" export DOCKER_CERT_PATH=”/home/user/.minikube/certs” export MINIKUBE_ACTIVE_DOCKERD=”minikube”

#To point your shell to minikube’s docker-daemon, # run: eval $(minikube -p minikube docker-env)

  1. To apply these variables,

    eval $(minikube -p minikube docker-env)

  2. Now need to build the image once again, so that it’s installed in the minikube registry, instead of the local one:

    docker build . -t forketyfork/hello-world

forketyfork/hello-world is the name of the docker image.

  1. Deploy the image to kubernetes or Minkube via the yaml configuartion file.

    kubectl create -f helloworld.yml

helloworld.yml is the name of the yml/yaml file.

  1. Now kubectl get pods to get the status of the pods

For further reference, https://medium.com/swlh/how-to-run-locally-built-docker-images-in-kubernetes-b28fbc32cc1d


The image is not available in minikube.

Minikube uses separate docker daemon. That's why, even though the image exists in your machine, it is still missing inside minikube.

First, send the image to minikube by,

docker save myImage | (eval $(minikube docker-env) && docker load)

This command will save the image as tar archive, then loads the image in minikube by itself.

Next, use the image in your deployment with image-pull-policy set to IfNotPresent

kubectl run myImage --image=myImage --port 3030 --image-pull-policy=IfNotPresent