Skip to content
SimplyMe
Go back

Building and Using Local Images in Minikube: Docker vs. Podman

Edit page

When developing Kubernetes applications locally, Minikube provides a convenient way to spin up a single-node cluster. A crucial part of this process is building and using your own Docker or Podman images within that Minikube environment. However, the approach varies depending on your chosen containerization tool.

Docker: The Traditional Approach

For many, Docker remains the go-to containerization platform. Minikube’s integration with Docker is relatively straightforward.

Using minikube docker-env

This method leverages Minikube’s built-in Docker daemon.

  1. Start Minikube with the Docker driver:
    bash minikube start --driver=docker
  2. Configure your Docker CLI:
    bash eval $(minikube docker-env)
    This command directs your local Docker commands to the Minikube Docker daemon.
  3. Build your image:
    bash docker build -t your-image-name:tag .
  4. Create your Kubernetes deployment YAML:
    yaml 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: your-image-name:tag imagePullPolicy: Never # Crucial for local images
  5. Apply the deployment:
    bash kubectl apply -f your-deployment.yaml

Using minikube image load

If you’ve already built your Docker image locally, you can load it into Minikube.

  1. Build your image:
    bash docker build -t your-image-name:tag .
  2. Load the image into Minikube:
    bash minikube image load your-image-name:tag
  3. Deploy as described in the previous section.

Using minikube image build

Minikube also has a command that builds images directly within the minikube enviroment.

  1. Build your image:
    bash minikube image build -t your-image-name:tag -f ./Dockerfile .
  2. Deploy as described in the first section.

Podman: The Daemonless Alternative

Podman offers a daemonless approach to containerization. While Minikube supports Podman, the integration requires careful consideration.

Minikube with CRI-O

When using Podman, Minikube typically relies on the CRI-O container runtime.

  1. Start Minikube with Podman and CRI-O:
    bash minikube start --driver=podman --container-runtime=cri-o
  2. Build your image with Podman:
    bash podman build -t your-image-name:tag .
  3. Ensure CRI-O can access the image:
    • This is the most challenging aspect. You might need to configure mount points or use tools like Podman Desktop to facilitate image transfer.
  4. Deploy with a similar YAML as above, using imagePullPolicy: Never.

Podman Desktop

Podman Desktop simplifies the process by providing integrations for pushing images into Minikube.

Key Considerations for Both

Conclusion

Building and using local images in Minikube is a fundamental part of local Kubernetes development. While Docker offers a smoother integration, Podman provides a viable alternative with its daemonless architecture. Understanding the nuances of each approach will help you streamline your development workflow.


Edit page
Share this post on:

Previous Post
IO Threads vs. Worker Threads in Quarkus: A Guide to Optimal Performance
Next Post
Kubernetes ConfigMaps: Centralized Configuration for Your Applications