4.1 KiB
title | weight | description | aliases | ||||
---|---|---|---|---|---|---|---|
Pushing images | 5 | There are many ways to push images into minikube. |
|
Cached Images
From the host, you can push a Docker image directly to minikube. It will also be cached for future cluster starts.
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 which are built-in to minikube.
minikube cache delete <image name>
For more information, see:
- [Reference: cache command]({{< ref "/docs/commands/cache.md" >}})
You must be using minikube with the container runtime set to Docker. This is the default setting.
Pushing directly to the in-cluster Docker daemon
When using a single VM of Kubernetes it's really handy to reuse the Docker daemon inside the VM; as 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 be able to work with the docker daemon on your mac/linux host use the docker-env command in your shell:
eval $(minikube docker-env)
You should now be able to use docker on the command line on your host mac/linux machine talking to the docker daemon inside the minikube VM:
docker ps
Remember to turn off the imagePullPolicy:Always
(use imagePullPolicy:IfNotPresent
or imagePullPolicy:Never
), as otherwise Kubernetes won't use images you built locally.
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 Registry
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
Use minikube ssh
to connect to the virtual machine, and run the docker build
there:
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).