In my deployment.yaml .the image is assigned like
- image: nexus.company.local:5000/company-ubuntu-32bit:2.0
In nexus, I update the image,but didn't change name and tag. I want to use the new image in k8s pod.So I try to use
imagePullPolicy: "Always" + delete the old pod
Now on the node, docker images can show the new hash of image. And in dashboard,I can see the event "pull image" successfully. But
kubectl get pod -n k8s-demo k8s-pod-build-32-d4794d44-zrgvh -o json
show that the new created pod is still using old image hash id.
How can I update the image without change the image's name or tag?
uupdate the shows:
kubectl get pod -n k8s-demo k8s-pod-build-32-6fbb6bf5cc-dtg4f -o json
"containerStatuses": [
{
"containerID": "docker://ef57cbdf31256556fbeda5df4247591ea74ddb71ca0aec512278079e6badc201",
"image": "nexus.company.local:5000/e7bld-cdc-32bit:2.0",
"imageID": "docker-pullable://nexus.company.local:5000/e7bld-cdc-32bit@sha256:45f6b42ab2f7629cf8032c09c78ccf7627ca6e71d5c15173f81217100f87eecb",
and the docker image on node:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus.company.local:5000/e7bld-cdc-32bit 2.0 49889fd96652 4 days ago 1.29GB
45f6b42ab2f76 AND 49889fd96652 is different.
I use local env,and the kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:18:23Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
nexus.company.local:5000/e7bld-cdc-32bit 2.0 sha256:45f6b42ab2f7629cf8032c09c78ccf7627ca6e71d5c15173f81217100f87eecb 49889fd96652 5 days ago 1.29GB
You are comparing docker image id
and it's digest
which are not the same thing. image id
is the hash of the JSON config of the local image. digest
is the hash of registry manifest.
kubectl get pod -n k8s-demo k8s-pod-build-32-6fbb6bf5cc-dtg4f -o json
"containerStatuses": [
{
"containerID": "docker://ef57cbdf31256556fbeda5df4247591ea74ddb71ca0aec512278079e6badc201",
"image": "nexus.company.local:5000/e7bld-cdc-32bit:2.0",
"imageID": "docker-pullable://nexus.company.local:5000/e7bld-cdc-32bit@sha256:45f6b42ab2f7629cf8032c09c78ccf7627ca6e71d5c15173f81217100f87eecb"
45f6b42ab2f7629cf8032c09c78ccf7627ca6e71d5c15173f81217100f87eecb
here is the digest.
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus.company.local:5000/e7bld-cdc-32bit 2.0 49889fd96652 4 days ago 1.29GB
49889fd96652
here is the image id.
If you want to see the digest of a local image, you can use
docker inspect --format='{{index .RepoDigests 0}} <image_name>'
docker inspect --format='{{index .RepoDigests 0}} nexus.company.local:5000/e7bld-cdc-32bit:2.0
in your case.