How to use local docker images with Minikube?

Better Stack Team
Updated on April 7, 2023

To use local Docker images with Minikube, you can follow these steps:

  1. Start the Minikube cluster by running the following command:

     
    minikube start
    
  2. Build the Docker image: Build the Docker image using the docker build command. For example, to build an image from a Dockerfile in the current directory, run the following command:

     
    docker build -t my-image .
    

    This will create a Docker image with the tag my-image.

  3. Load the image into Minikube: Load the Docker image into Minikube by running the following command:

     
    minikube image load my-image
    

    This will load the my-image Docker image into the Minikube Docker daemon.

  4. Use the image in a Kubernetes deployment: You can now use the my-image Docker image in a Kubernetes deployment by specifying the image name in the deployment manifest. For example:

     
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: my-app
      template:
        metadata:
          labels:
            app: my-app
        spec:
          containers:
          - name: my-container
            image: my-image
            ports:
            - containerPort: 8080
    

    This will create a deployment with one replica and a container named my-container, which uses the my-image Docker image.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack