Building an image and testing it in Minikube
With Podman Desktop, you can build an image with your container engine, and test it in your local Minikube-powered Kubernetes cluster.
Prerequisites
- You onboarded a container engine.
- You onboarded a Minikube cluster.
- You have set your Kubernetes context to your Minikube cluster.
- A container definition file:
Containerfile
orDockerfile
.
Procedure
-
Build your image:
- Open Images > Build an image.
- Containerfile path: select your
Containerfile
orDockerfile
. - Build context directory: optionally, select a directory different from the directory containing your
Containerfile
orDockerfile
. - Image Name: enter your image name
my-custom-image
. - Click Build.
- Wait for the image build to finish.
- Click Done to get back to the images list.
-
Push your image to your Minikube cluster:
- Search images: enter your image name
my-custom-image
to find the image. - Click > Push image to Minikube cluster.
- Search images: enter your image name
-
Test your image by creating a container:
- Click to open the Create a container from image dialog.
- Container name: enter
my-custom-image-container
. - Review the parameters that Podman Desktop has detected from your image definition.
- Click Start Container to start the container in your container engine.
-
Test your image and container on your Minikube cluster:
- Search containers: enter
my-custom-image-container
to find the running container. - Click > Deploy to Kubernetes to open the Deploy generated pod to Kubernetes screen.
- Pod Name: keep the proposed value
my-custom-image-container-pod
. - Use Kubernetes Services: select Replace
hostPort
exposure on containers by Services. It is the recommended way to expose ports, as a cluster policy might prevent to usehostPort
. - Expose service locally using Kubernetes LoadBalancer: if your container is exposing a service, you can use
minikube service
to get a web browser or an URL to use. - Optionally, if your container is exposing more than one port, select the port to expose.
- Kubernetes namespaces: select
default
. - Click Deploy.
- Wait for the pod to reach the state: Phase: Running.
- Click Done.
- Search containers: enter
Verification
- The Pods screen lists the running
my-image-container-pod
pod. - Click on the pod name to view details and logs.
- Optionally, if your container is exposing a service, go to the server URL: your application is running.