How to run docker image in minikube?


by adolf , in category: General Help , 3 months ago

How to run docker image in minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by caesar_kertzmann , 3 months ago


To run a Docker image in minikube, you can follow these steps:

  1. Start minikube: Open a terminal and run the minikube start command. This will start a local Kubernetes cluster using minikube.
  2. Set minikube's Docker environment: Run the command eval $(minikube docker-env) to set the Docker environment variables to point to the minikube Docker daemon.
  3. Build the Docker image: Navigate to the directory where your Dockerfile is located and build the Docker image using the docker build command. For example, docker build -t myimage:latest .. This will build the Docker image using the Docker daemon of minikube.
  4. Run the Docker image in minikube: Use the kubectl run command to run the Docker image in minikube. For example, kubectl run mypod --image=myimage:latest --image-pull-policy=Never. This will create a new pod in the Kubernetes cluster running the specified Docker image.

After these steps, you should have the Docker image running in minikube as a pod. You can use kubectl get pods to check its status and kubectl logs <pod-name> to view its logs.