docker - How to setup docker registry in k8s cluster?
问题描述
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:
- https://github.com/SeldonIO/k8s-local-docker-registry
- https://github.com/alexellis/k8s-tls-registry
- https://github.com/ContainerSolutions/trow
> set -x && curl -X GET 192.168.64.3:31549/v2/_catalog
+ curl -X GET 192.168.64.3:31549/v2/_catalog
{"repositories":[]}
解决方案
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" ]
}
推荐阅读
- jquery - 使用 ajax 请求 googleOauth 的 MVC 应用程序 4.5 中的 CORS 问题
- go - 从不同的目录转换类型
- sql - 在 sql 中从 100000187^Visit-NCH 中选择 100000187?
- android - 具有动态页面高度的 ScrollView 中的 ViewPager
- android - 测试 google play 购买时出现“您的交易无法完成”错误
- javascript - Firefox 57+ 共享工作者错误的功能检测
- postgresql - psql 导出查询到 csv 错误
- python - Pyqt5:动态地将表格添加到选项卡
- wordpress - WooCommerce 下载中的动态简码
- javascript - 向下滚动后转到首页按钮