Search code examples
dockerkubernetesregistrydocker-desktop

Issue while accessing registry deployed in Kubernetes from Docker Desktop


I am running Docker Desktop on W10 to try Camel-k. Camel-K required a repository to push the images, once it completed build in Kubernetes platform. I don't want docker.io to be configured, so deployed docker registry in Kubernetes running on top of Docker Desktop.

Deployed: https://github.com/Joxit/docker-registry-ui/tree/master/examples/helm/docker-registry-ui

**kubectl get pod:**
private-registry-registry-docker-registry-ui-69bdb85647-rmvhs

private-registry-ui-docker-registry-ui-6f49d78f58-d6qqt

updating docker deamon.js

{
  "registry-mirrors": [],
   "insecure-registries" : [
      "private-registry-registry-docker-registry-ui:5000"
    ],
   "debug" : true,
   "experimental": true
}

Adding host entry:

127.0.0.1 private-registry-registry-docker-registry-ui

Kubectl port-forward to access port 5000:

kubectl port-forward private-registry-registry-docker-registry-ui-69bdb85647-rmvhs 5000:5000

pushing an image

docker tag alpine:latest private-registry-registry-docker-registry-ui:5000/alpine:latest

docker push private-registry-registry-docker-registry-ui:5000/alpine:latest

The push refers to repository [private-registry-registry-docker-registry-ui:5000/alpine]
***Get http://private-registry-registry-docker-registry-ui:5000/v2/: dial tcp 127.0.0.1:5000: connect: connection refused***

Does anyone faced similar issue while accessing registry deployed in Kubernetes? Please suggest what's needs to be done in order to fix this problem. I found similar problem for Docker Desktop mac and have tried but no luck.


Solution

  • Your docker deamon.js should look like this:

    {
      "registry-mirrors": [],
       "insecure-registries" : [
          "localhost:5000",
          "127.0.0.1:5000",
          "private-registry-registry-docker-registry-ui:5000"
        ],
       "debug" : true,
       "experimental": true
    }
    

    When you want to add insecure registry after updating docker deamon.js you have to restart docker. Make sure you have done this. Make sure that port 5000 is open on destination machine. Also check firewalls.

    Speaking about pushing image, I think you don't have a default registry. You have to:

    1. Start the registry container $ docker run -d -p 5000:5000 --restart=always --name registry registry:2

    Check the registry container is running, execute command: $ docker ps | grep registry, and then proceed further - tag and push your image.

    1. Tag your image ($ docker tag ... )

    2. Push your image using command ($ docker push ...)

    Take a look on similar problems: docker-push-issue, connection-refused.