k8s使用本地docker镜像

k8s use the local docker image

当我尝试在 microk8s 中创建部署时,docker 图像出现问题。

我的 yaml 看起来像这样,如您所见,我使用 IfNotPresent ImagePullPolicy 来创建我的部署:

我把图片拉到我的 docker:

但是k8s好像找不到我电脑里面的图片:

谁能帮我解决问题?

将@朱江源解决方案发布为社区维基。

Use "docker tag k8s.gcr.io/heapster-grafana-amd64:v1.3.3 {your dockerhub account}/heapster-grafana-amd64:v1.3.3" to rename your image.

Then use "docker push {your dockerhub account}/heapster-grafana-amd64:v1.3.3" to push the image into you dockerhub. At the same time, you need to change the image location of your pod to "{your dockerhub account}/heapster-grafana-amd64:v1.3.3". In this way, you can use "docker create -f xxx,yaml" to create your pod.

此外还有container registry proxies来自中国的用户:

global                 proxy in China       format

dockerhub (docker.io)  dockerhub.azk8s.cn   dockerhub.azk8s.cn/<repo-name>/<image-name>:<version>
gcr.io                 gcr.azk8s.cn         gcr.azk8s.cn/<repo-name>/<image-name>:<version>
quay.io                quay.azk8s.cn        quay.azk8s.cn/<repo-name>/<image-name>:<version>
mcr.microsoft.com      mcr.azk8s.cn         mcr.azk8s.cn/<repo-name>/<image-name>:<version>