How to use local docker images with Minikube?

Better Stack Team
Updated on October 5, 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.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github