RrR-
RrR-

Reputation: 1430

Unable to pull images from insecure registry through minikube

I have a local insecure docker registry which I created using the command:

docker run -d -p 5000:5000 --restart=always --name registry registry:2` 

I have added this to the /etc/docker/daemon.json as well. I tagged several images in the format localhost:5000/<orgname>/<imagename>:<tag> and pushed them to the insecure registry.

When I run curl -X GET localhost:5000/v2/_catalog I can see that they are available inside the local registry.

I started minikube with the command minikube start --insecure-registry="localhost:5000". Here, my default driver is docker (I also tried with kvm2). I enabled the registry addon as well using the command minikube addons enable registry

I have a configmap which states the image in the format I mentioned earlier. When I apply this using kubectl, I get an ImagePullBackoff error with the error message

Failed to pull image "localhost:5000/org/product:tag": rpc error: code = Unknown desc = Error response from daemon: manifest for localhost:5000/org/product:tag not found: manifest unknown: manifest unknown

Any ideas as to why this is happening?

Docker version: 19.03.8, build afacb8b7f0

Minikube version: 1.9.2

Ubuntu 20.04 LTS

Upvotes: 5

Views: 3603

Answers (4)

Abilash Sethu
Abilash Sethu

Reputation: 51

One thing noticed here, before you start the minikube with the insecure arguments, Make sure to delete the cluster, Otherwise the changes won't effect

minikube delete

minikube start --insecure-registry="<IP-of-your-computer>:5000"

After that you could see the insecure registries been added on the minikube docker daemon

minikube ssh

docker info

Scroll to the end of the details.

Upvotes: 1

Neeraj Gulia
Neeraj Gulia

Reputation: 700

I used following on Ubuntu 20.04

  1. Start the minikube with insecure-registry as your computer's ip:
    minikube start --insecure-registry="<your-computer-ip>:5000"
  2. Enable the registry:
    minikube addons enable registry
  3. make sure registry is up and running:
    kubectl get service --namespace kube-system
> NAME       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                AGE
> kube-dns   ClusterIP   10.96.0.10     none          53/UDP,53/TCP,9153/TCP 54m
> registry   ClusterIP   10.98.34.133   none          80/TCP,443/TCP         37m
  1. Portforward to localhost:
    kubectl port-forward --namespace kube-system service/registry 5000:80
  2. Build and push your images to localhost
    docker tag my/image localhost:5000/myimage
    docker push localhost:5000/myimage
  3. Use the image in deployment yaml and apply using kubectl in yaml file:
containers:
        - name: app-name
          image: localhost:5000/image-name:latest

Upvotes: 1

RrR-
RrR-

Reputation: 1430

I was able to solve this issue by replacing localhost with my IP.

minikube start --insecure-registry="<IP-of-your-computer>:5000"

Have to use the IP instead of localhost when tagging and pushing images to te local registry as well.

Upvotes: 1

Rico
Rico

Reputation: 61689

Well, the minikube K8s subnet is different from the one that your registry is running so localhost is not going to work without some tweaks. I recommend following the minikube official guide and not run:

docker run -d -p 5000:5000 --restart=always --name registry registry:2` 

In essence, it says that after running:

minikube addons enable registry

Then when you create your minikube instance

minikube start --drive=docker --insecure-registry "10.0.0.0/24"

Upvotes: 2

Related Questions