Kubernetes cannot pull image from private docker image repository

后端 未结 7 1200
Happy的楠姐
Happy的楠姐 2020-12-17 08:22

I have problem with kubernetes (minikube) and pull images from local image repository on docker. Docker repository was created:

docker run --entrypoint htpas         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-17 09:15

    For minikube to pull from your own local docker registry, the tag affects the pull policy. Per Images docs, pull policy is IfNotPresent by default EXCEPT if

    1. you use :latest as the tag for the image to use
    2. OR you omit the tag for the image to use.

    In those cases the pull policy will effectively default to Always, which will attempt to pull from docker hub. This will cause minikube to be unable to fetch local images that have no tag or "latest" tag.

    Moral of the story is, don't rely on the default because it is too confusing :)

    So always explicitly state the pull policy:

    1. when deploying into minikube the pull policy should be IfNotPresent or Never for the local images
    2. when deploying into a cloud host (like AWS), pull policy should be as for public images (see below)
    3. the pull policy should be Always for those public images that use a tag like "latest" or "stable" (because the image the tag points will change over time), and IfNotPresent for tags that always point to the same image (to avoid fetching more than necessary)

    This means that if you avoid using tags like latest and stable etc, there is only one rule to follow:

    1. explicitly set the imagePullPolicy in your spec (or on the command line in the case of run) to IfNotPresent, as this is will always look for it locally first, and go to public registry if it is not found locally, and this will work whether or not you are deploying into minikube or cloud.

提交回复
热议问题