Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot pull image from minikube docker

When I try to run a container in the cluster, I get a message "deployment test created" but when I look at the dashboard I can see that its in an error state (Failed to pull image..., it was not able to pull the image from the local minikube docker env due to authorization issues

My steps were:

  1. Start minikube using hyperv and setting the --insecure-registry switch to 10.0.0.0/8, also tried 0.0.0.0/0 - Kubernetes version 1.9.0 also tried 1.8.0
  2. Set the docker env to the minikube docker via minikube docker-env | Invoke-Expression
  3. build docker image - image builds and exists in minikube local docker
  4. kubectl run test --image test-service --port 1101

This is the result:

Failed Deployment

What am I missing?

like image 241
Tim Jarvis Avatar asked Feb 16 '18 00:02

Tim Jarvis


Video Answer


3 Answers

As discussed in the comments, openfaas/faas-netes issue 135 illustrates a similar issue, and mention as a possible solution:

imagePullPolicy if not mentioned should have defaulted to Never instead of Always.

The OP Tim Jarvis realized then:

I realized it was not an auth issue, but that it was always wanting to pull from an external repo.
The fix for me was to use the imagePullPolicy of IfNotPresent.

like image 142
VonC Avatar answered Oct 08 '22 01:10

VonC


This also happened with me, it is important to check the policy to send retrieve your image, there are some ways as described in some forums, you can start your minikube by setting a registry of your preference as below, being a path.

$ minikube start --cpus 2 --disk-size 50g --memory 5000 --insecure-registry your.registry.com:5000

another way is at the beginning of your minikube to present the environment variables through the docker-env, as follows and generate build of your image after the command.

$ eval $(minikube docker-env)

another alternative is to import the image to existing through the docker load.

like image 1
ovrdoz Avatar answered Oct 08 '22 01:10

ovrdoz


Set the following property within the container definition:

imagePullPolicy: IfNotPresent

Example:

  ...
  containers:
    - name: podhealthexample
      image: podhealth-pod-a:latest
      ports:
        - containerPort: 80
      imagePullPolicy: IfNotPresent
like image 1
Chris Stryczynski Avatar answered Oct 08 '22 00:10

Chris Stryczynski