local docker image on minikube

+5 votes
I want to use local docker images directly with minikube instaed of uploading and downloading them and then deploying them on minikube. How do i go about this?
Aug 29, 2018 in Kubernetes by lina
• 8,220 points

4 answers to this question.

0 votes

Use the following steps:

  1. set the environment variables with eval $(minikube docker-env)
  2. build the image with the Docker daemon of Minukube (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.
answered Aug 29, 2018 by Kalgi
• 52,360 points
+1 vote

Use a local registry:

docker run -d -p 5000:5000 --restart=always --name registry registry:2

Now tag your image properly:

docker tag ubuntu localhost:5000/ubuntu

Note that localhost should be changed to dns name of the machine running registry container.

Now push your image to local registry:

docker push localhost:5000/ubuntu

You should be pull it back:

docker pull localhost:5000/ubuntu

Now change your yaml file to use local registry.

answered Aug 29, 2018 by Hannah
• 18,570 points
+1 vote

Try something like this:

# Start minikube
minikube start

# Set docker env
eval $(minikube docker-env)

# Build image
docker build -t foo:0.0.1 .

# Run in minikube
kubectl run hello-foo --image=foo:0.0.1 --image-pull-policy=Never

# Check that it's running
kubectl get pods
answered Aug 29, 2018 by Nilesh
• 7,050 points
+3 votes

I know this is an old question - but it came up number 1 on my Google search - so I thought I'd add what I learnt.

You can use: minikube cache add <image_name>.

This will still require you to upload it (to minikube), but it'll save the download.

You'll also need to set imagePullPolicy to Never.

answered Feb 1, 2020 by anonymous
Thanks for your contribution.

Please register at Edureka Community and earn credits for every contribution. A contribution could be asking a question, answering, commenting or even upvoting/downvoting an answer or question.

These credits can be used to get a discount on the course. Also, you could become the admin at Edureka Community with certain points.


Related Questions In Kubernetes

0 votes
1 answer

Running a custom docker image on GKE

You'll have tom push your image to ...READ MORE

answered Sep 18, 2018 in Kubernetes by ajs3033
• 7,300 points
0 votes
1 answer

Using local docker images with Minikube

You can reuse the Docker daemon from ...READ MORE

answered Jan 3, 2019 in Kubernetes by ajs3033
• 7,300 points
0 votes
2 answers

Using a local image to create a pod in K8s

I'm not sure but you can try ...READ MORE

answered Apr 29, 2019 in Kubernetes by Vishaka
0 votes
2 answers

run private docker images on Google Container Engine

run docker login on minions before starting.  ...READ MORE

answered Aug 30, 2018 in Kubernetes by Nilesh
• 7,050 points
0 votes
1 answer

image can't be pulled error when I try to pull a docker image - kubernetes

I think the image is being pulled ...READ MORE

answered Sep 4, 2018 in Kubernetes by Kalgi
• 52,360 points
0 votes
1 answer

Accessing private Docker Hub repository from Kubernetes on Vagrant

In order to pull private dockerhub hosted ...READ MORE

answered Sep 18, 2018 in Kubernetes by DareDev
• 6,890 points
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP