Kubernetes use local docker image is nothing but create Kubernetes image locally and deploy the same on Kubernetes cluster locally; the first step is to deploy our application on Kubernetes to build the docker image. Next, we need to use minikube to run the Kubernetes in our local environment.
Click the Docker icon in the status bar, go to “Preferences”, and on the “Kubernetes” tab check “Enable Kubernetes” as shown in the figure below. This will start a single node Kubernetes cluster for you and install the kubectl command line utility as well.
I was able to run a local image by setting the imagePullPolicy
to Never
.
For example:
apiVersion: v1
kind: Pod
metadata:
name: local-image-test
spec:
containers:
- name: local-image-container
image: local-image:latest
imagePullPolicy: Never
(Credit to https://github.com/kubernetes/kubernetes/issues/1293#issuecomment-357326426 for this solution)
Use tagged version of image rather than latest because If you are shipping Docker images to a production environment, you should just ignore the latest tag. Don’t use it. Don’t be tempted by it. It’s easy to look at it and think that your deployment script should just pull “latest” and your build process will ensure that’s valid.
In addition to techtrainer comment and answer, I would like to provide some examples of how to do it.
General rule. You have to use tag version of images rather than latest
.
With Docker tags, the more specific you can get, the better. Get specific to avoid using the wrong image.
Consider this if you don't want your colleagues or other Docker users pulling down images and having no idea how recent they are.
Get specific to avoid such issues.
docker tag IMAGE ID image/TAG:version.d.m.y
For better management of your images, you should have some smart convention of naming. I prefer to use a stage, version, and date of creation of the image. For example:
docker tag 113a43faa138 ubuntu/prod:v1.8.6.2018
It means production stage, version 1, created on 8 June 2018.
And that's all. Your version is available, and naming is easier to understand for you and further users of this image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With