I created a docker image and uploaded it to Docker Hub.
My goal is that every time a pod is created, Openshift will pull the image from Docker Hub, while ignoring any cache it has.
I created a new app using the following command:
oc new-app --docker-image=docker.io/barak1412/docker_test:v1 --name=docker-test-app
And also changed the image pulling policy in the development YAML:
imagePullPolicy: Always
But still, Openshift keeps loading the image from somewhere in its internal cache, and as a result, the application is not updating.
Any suggestions?
Thanks.
2
Answers
When you create an application using
oc new-app
, not only do you create aDeployment
but in the background anImageStream
is configured as well. The application in the Deployment then references this ImageStream.So to update your
Deployment
do one of the following:Edit your
Deployment
usingoc edit deployment <name>
and set the Docker Hub container image as theimage
.Use
oc get is
to find the name of your ImageStream and then useoc import-image <name>
to update it to the latest version. You can enable automatic updates by using--scheduled
: Configuring periodic importing of image stream tagsSetting this property
imagePullPolicy: Always
is the correct way. However, note that there is no way no you can disable the ImageStreams (internal cache) on OpenShift by default. The first time kubernetes pulled the image from the DockerHub, this image with the exact digest is cached. So the next time you try to pull, kubelet queries for the exact digest locally and pulls with the resolved digest.Always
If you want OpenShift to pull a new image from DockerHub:
v1
. This new image will have a new digest created by DockerHub itself.ImagePullPolicy
set toalways
, kubelet will first check local cache’s image (ImageStreams) and try to match with the new image and it’s digest value.Reference:
https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy