Paul Rousseau
Paul Rousseau

Reputation: 561

Kubernetes Private Docker Registry not working - Command-Line Alternative working, but k8s unable to pull image

I have following docker-compose.yaml for a private docker registry to be run on minikube:

version: '3'
services:
  registry:
    restart: always
    image: registry:2
    command: ["/bin/sh", "-ec","sleep 1000"]
    ports:
      - 443:443
    environment:
      REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
      REGISTRY_HTTP_TLS_KEY: /certs/domain.key
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
    volumes:
      - /home/usr/registry/data:/var/lib/registry
      - /home/usr/registry/certs:/certs
      - /home/usr/registry/auth:/auth

When I do kompose up, the registry should be up and running. But doing docker login localhost:443 only gives me a connection refused error. If I run

docker run -d   --restart=always   --name registry   -v `pwd`/auth:/auth   -v `pwd`/certs:/certs   -v `pwd`/certs:/certs   -e REGISTRY_AUTH=htpasswd   -e REGISTRY_AUTH_HTPASSWD_REALM="Registry Realm"   -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd   -e REGISTRY_HTTP_ADDR=0.0.0.0:443   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt   -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key   -p 443:443   registry:2

everything works fine and I can log into my private registry. The reason this is important is that I have a webapp-image that is in the private registry and should be pulled by kubernetes (minikube) from it. However, I always get a CrashLoopBackoff error which I deem due to the fact that the registry cannot be run from kubernetes and incidentally not be accessed by it. What am I getting wrong?

Upvotes: 1

Views: 147

Answers (1)

Paul Rousseau
Paul Rousseau

Reputation: 561

The solution is to set up a registry in minikube and port-forward to from localhost so the image gets pushed onto the minikube regsitry.

Upvotes: 1

Related Questions