DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?

Trending

  • Creating a Web Project: Caching for Performance Optimization
  • Modern Test Automation With AI (LLM) and Playwright MCP
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • SaaS in an Enterprise - An Implementation Roadmap
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Running Local Docker Images in Kubernetes

Running Local Docker Images in Kubernetes

This short tutorial gives you step-by-step instructions on how to run your local Docker images on Kubernetes using minikube.

By 
Milind Deobhankar user avatar
Milind Deobhankar
·
Updated Jun. 19, 19 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
98.2K Views

Join the DZone community and get the full member experience.

Join For Free

Definitely one of the easiest deployment of Kubernetes in the local environment is using the minikube.

One should first understand that minikube is a virtual machine with the Docker engine installed. Docker engine running on your local machine has a different Docker daemon than the one installed in minikube.

You may also enjoy Linode's Beginner's Guide to Kubernetes.

Minikube's strategy is to pull the Docker images from the repository by default. There are predefined default repositories configured, but we will not go into those details. When you run the following command for creating the pod, it will fail with an error because it will not be able to pull the image from the repository.

kubectl run discovery –image=myproject/myimage –port=8761


This is because it is not able to find the repo. If you do ssh into minikube:

minikube ssh

>docker images


Then you will notice that there is no image for you to run.

There are lots of solution to this problem, like creating the repo and pushing the image to that, copying the image from local to minikube, etc. But the easiest solution is to build the image into minikube itself.

First, note that when you execute the command docker images  from your local prompt, it will display the images present in your local Docker environment.

Now we point local Docker environment to minikube using the following command:

eval $(minikube docker-env)


Now if you execute the following command from your terminal:

docker images


It will show the images in minikube and not from your local Docker environment.

Finally, build the image from your terminal:

docker build -t myproject/myimage .


The image will get build  into minikube and not into your local Docker environment. Verify this with the following command:

minikube ssh

>docker images


If you execute the following command now:

kubectl run discovery –image=myproject/myimage –port=8761


It will still fail with the same problem because Kubernetes, by default, works on the pull strategy and we need to disable it by executing the following command:

kubectl run discovery –image=myproject/myimage –image-pull-policy=Never –port=8761


Now if you inspect the pods:

kubectl get pods


It will show that it is successfully running.

Docker (software) Kubernetes

Opinions expressed by DZone contributors are their own.

Related

  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • A Guide to Container Runtimes
  • Docker vs Kubernetes: Which to Use and When?

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!