minikube/site/content/en/docs/handbook/pushing.md

5.9 KiB

title weight description aliases
Pushing images 5 comparing 3 ways to push your image into minikiube.
/docs/tasks/building
/docs/tasks/caching
/docs/tasks/podman_service
/docs/tasks/docker_daemon

What is best method to push image to minikiube ?

the answer depends on the container-runtime driver you choose. Here is a comparison table to help you choose:

Method Supported Runtimes Supported Drivers* Performance
docker-env command only docker all good
podman-env command only cri-o all good
cache add command all all ok
registry addon all all but docker on mac ok
minikube ssh all all best
  • note1 : the default container-runtime on minikube is 'docker'.
  • note2 : 'none' driver (bare metal) does not need pushing image to the cluster, as any image on your system is already available to the kuberentes.

Pushing directly to the in-cluster Docker daemon

When using a container or VM driver (all drivers except none), you can reuse the Docker daemon inside minikube cluster. this means you don't have to build on your host machine and push the image into a docker registry. You can just build inside the same docker daemon as minikube which speeds up local experiments.

To point your terminal to use the docker daemon inside minikube run this:

eval $(minikube docker-env)

now any 'docker' command you run in this current terminal will run against the docker inside minikube VM or Container. Try it:

docker ps

now you 'build' against the docker inside minikube. which is instantly accessible to kubernetes cluster.

''' docker build -t myimage . '''

Remember to turn off the imagePullPolicy:Always (use imagePullPolicy:IfNotPresent or imagePullPolicy:Never), as otherwise Kubernetes won't use images you built locally.

docker-env will be

Please remember by closing the terminal, you will go back to using your own system's docker daemon. to verify your terminal is using minikuber's docker-env you can check the value of the environment MINIKUBE_ACTIVE_DOCKERD

more information on docker-env

Push images using Cache Command.

From the host, you can push a Docker image directly to minikube. It will also be cached for all minikube clusters .

minikube cache add ubuntu:16.04

The add command will store the requested image to $MINIKUBE_HOME/cache/images, and load it into the VM's container runtime environment next time minikube start is called.

To display images you have added to the cache:

minikube cache list

This listing will not include the images minikube's built-in system images.

to ensure your running cluster has cached the updated images use reload:

minikube cache reload
minikube cache delete <image name>

For more information, see:

  • [Reference: cache command]({{< ref "/docs/commands/cache.md" >}})

Pushing directly to in-cluster CRIO

To push directly to CRIO, configure podman client on your mac/linux host using the podman-env command in your shell:

eval $(minikube podman-env)

You should now be able to use podman on the command line on your host mac/linux machine talking to the podman service inside the minikube VM:

podman-remote help

Remember to turn off the imagePullPolicy:Always (use imagePullPolicy:IfNotPresent or imagePullPolicy:Never), as otherwise Kubernetes won't use images you built locally.

Pushing to an in-cluster using a Registry addon

For illustration purpose, we will assume that minikube VM has one of the ip from 192.168.39.0/24 subnet. If you have not overridden these subnets as per networking guide, you can find out default subnet being used by minikube for a specific OS and driver combination here which is subject to change. Replace 192.168.39.0/24 with appropriate values for your environment wherever applicable.

Ensure that docker is configured to use 192.168.39.0/24 as insecure registry. Refer here for instructions.

Ensure that 192.168.39.0/24 is enabled as insecure registry in minikube. Refer here for instructions..

Enable minikube registry addon:

minikube addons enable registry

Build docker image and tag it appropriately:

docker build --tag $(minikube ip):5000/test-img .

Push docker image to minikube registry:

docker push $(minikube ip):5000/test-img

Building images inside of minikube using SSH

Use minikube ssh to go inside a minikube node, and run the docker build directly there. any command you run there will run against the same daemon that kubernetes is using.

docker build

For more information on the docker build command, read the Docker documentation (docker.com).

For Podman, use:

sudo -E podman build

For more information on the podman build command, read the Podman documentation (podman.io).

to exit minikube ssh and come back to your terminal type:

exit