How to setup docker registry in k8s cluster?

6/26/2020

There is no requirement for secure registry. I just need to connect to a registry using http protocol.

The registry must be on a pod and not directly on the VM.

docker has registry image that is made just for this purpose but when I'm using it inside a pod, docker fails to communicate with it because it thinks its a secure registry:

> docker pull 192.168.64.3:31549/repo630444582240256/image1

Using default tag: latest
Error response from daemon: Get https://192.168.64.3:31549/v2/: http: server gave HTTP response to HTTPS client

I came across these solutions but each of them requires installing prerequisits in the VM or doesn't use a pod to setup a registry:


> set -x && curl -X GET 192.168.64.3:31549/v2/_catalog

+ curl -X GET 192.168.64.3:31549/v2/_catalog
{"repositories":[]}
-- Stav Alfi
docker
docker-registry
kubernetes

2 Answers

6/26/2020

I tried this on my local machine: https://github.com/SeldonIO/k8s-local-docker-registry and works like a charm. (I had to make a few changes to the K8s manifests so they support the latest K8s)

You can get to the registry using curl -X GET 192.168.64.3:31549/v2/_catalog which means there is no redirect to https.

I believe your docker client config doesn't have explicit Insecure Registry config for 192.168.x.x. You can check with:

$ docker info | grep -i -A5 'Insecure Registries'
 Insecure Registries:
  10.96.0.0/12
  127.0.0.0/8
  192.168.64.0/24  <== should have something like this

If not you can configure your 192.168.0.0/24 as an insecure registry in the daemon.json config:

{
  "insecure-registries" : ["10.96.0.0/12", "127.0.0.0/8", "192.168.64.0/24" ]
}
-- Rico
Source: StackOverflow

6/28/2020

just came across another path where you can add the insecure registries

$ vi /var/lib/boot2docker/profile  

add the following

EXTRA_ARGS='
--label provider=virtualbox
--insecure-registry 127.0.0.0/8
--insecure-registry 192.168.99.0/24
'

restart docker daemon

$ /etc/init.d/docker restart  
-- Abhishek D K
Source: StackOverflow