允许访问 gitlab.com

问题描述

我正在尝试在 minishift 中创建新应用。第一个命令是:

oc new-app https://gitlab.com/practical-openshift/hello-world.git

结果:

--> Found container image 2b6ec7e (10 hours old) from Docker Hub for "golang:alpine"

* An image stream tag will be created as "golang:alpine" that will track the source image
* A Docker build using source code from https://gitlab.com/practical-openshift/hello-world.git will be created
  * The resulting image will be pushed to image stream tag "hello-world:latest"
  * Every time "golang:alpine" changes a new build will be triggered

--> Creating resources ...
    imagestream.image.openshift.io "golang" created
    imagestream.image.openshift.io "hello-world" created
    buildconfig.build.openshift.io "hello-world" created
    deployment.apps "hello-world" created
    service "hello-world" created
--> Success
    Build scheduled,use 'oc logs -f buildconfig/hello-world' to track its progress.
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose service/hello-world'
    Run 'oc status' to view your app.

所以,当我跑步时:

oc logs -f buildconfig/hello-world

出现错误

cloning "https://gitlab.com/practical-openshift/hello-world.git" ...
WARNING: timed out waiting for git server,will wait 1m4s
error: fatal: unable to access 'https://gitlab.com/practical-openshift/hello-world.git/': Could not resolve host: gitlab.com; UnkNown error

我试着运行这个:

 git config --global --unset http.proxy
 git config --global --unset https.proxy

但是没有用。那么,我该如何解决我的问题?

解决方法

尝试使用hostAlias。添加到您的 buildconfig yaml。

spec:
  hostAliases:
  - ip: "172.65.251.78"
    hostnames:
    - "gitlab.com"

如果它不起作用,请将其添加到您的主机文件中。