openshift起源与本地docker注册表

时间:2016-07-16 03:17:14

标签: docker openshift

是openshift的新手,我正在尝试基本设置。我的Windows笔记本电脑里面的Ubuntu VM上安装了docker和openshift。我没有任何问题,单独使用docker并从我的本地注册表中推送或拉出。我在openshift原点使用oc new-app命令时遇到问题。

我的虚拟机中运行了本地注册表

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                          NAMES
26d3a527398d        registry:2          "/bin/registry serve "   16 minutes ago      Up 16 minutes       0.0.0.0:443->443/tcp, 0.0.0.0:5000->5000/tcp   registry

我已将图片推送到此注册表

docker images myregistry.com:5000/ubuntu
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
myregistry.com:5000/ubuntu   latest              cf62323fa025        7 days ago          125 MB

当我尝试在openshift中使用此图像时,我得到以下错误

./oc new-app --docker-image=myregistry.com:5000/ubuntu
error: can't look up Docker image "myregistry.com:5000/ubuntu": Internal error occurred: Get https://myregistry.com:5000/v2/: http: server gave HTTP response to HTTPS client
error: no match for "myregistry.com:5000/ubuntu"

The 'oc new-app' command will match arguments to the following types:

  1. Images tagged into image streams in the current project or the 'openshift' project
     - if you don't specify a tag, we'll add ':latest'
  2. Images in the Docker Hub, on remote registries, or on the local Docker engine
  3. Templates in the current project or the 'openshift' project
  4. Git repository URLs or local paths that point to Git repositories

--allow-missing-images can be used to point to an image that does not exist yet.

See 'oc new-app -h' for examples.

这与我的DNS解析有关吗?如何在我的openshift源中使用我的本地注册表

1 个答案:

答案 0 :(得分:1)

openshift/origin/pkg/diagnostics/pod/auth.go#authenticateToRegistry()中的代码提及:

    case strings.Contains(secError.Error(), "tls: oversized record received"),
    strings.Contains(secError.Error(), "server gave HTTP response to HTTPS"):
            r.Debug("DP1015", "docker-registry not secured; falling back to cleartext connection")

Issue 6516提及:

  

如果您的注册表需要身份验证,则问题就在于此。 new-app无法从需要身份验证的注册表中提取图像(存在此问题),因此只要注意图像在注册表中不存在。

Issue 6540(OC 1.1.1)应该解决这个问题:

  

new-app可以使用看似仅存在于本地的图像(因为new-app无法访问注册表)。它将继续定义预期的openshift对象(deploymentconfig等),并引用该图像   如果节点也无法提取图像,则部署最终仍会失败。 (但与new-app不同,nodes能够从安全注册表中提取图像)

OP Raghavan报告in the comments已使用“How to Setup a DNS Server for a Home Lab on Ubuntu 14.04”设置DNS

  

我在--insecure-registry文件中添加了DNS和/etc/default/docker选项

DOCKER_OPTS=--dns 10.0.3.1 --insecure-registry ns1.myregistry.com:5000
  

此处10.0.3.1是我的DNS服务器,也是使用主机名ns1.myregistry.com运行docker注册表的服务器