【问题标题】:How to deploy from docker hub to openshift?如何从 docker hub 部署到 openshift?
【发布时间】:2019-05-09 11:23:14
【问题描述】:

我正在尝试从 openshift 上的 docker hub 部署一个 docker 映像。

我用一个简单的 Spring Boot Rest 应用程序创建了一个图像: https://hub.docker.com/r/ernst1970/my-rest

登录到 openshift 并选择我做的正确项目后

oc new-app ernst1970/my-rest

我得到了

W0509 13:17:28.781435   16244 dockerimagelookup.go:220] Docker registry lookup failed: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Clien
t.Timeout exceeded while awaiting headers)                                                                                                                                                 
error: Errors occurred while determining argument types:                                                                                                                                   

ernst1970/my-rest as a local directory pointing to a Git repository:  GetFileAttributesEx ernst1970/my-rest: The system cannot find the path specified.                                    

Errors occurred during resource creation:                                                                                                                                                  
error: no match for "ernst1970/my-rest"                                                                                                                                                    

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.                                                                                                                                                          

我也试过

oc new-app mariadb

但是得到了同样的错误信息。

我认为这可能是代理问题。所以我将代理添加到我的.profile

export http_proxy=http://ue73011:secret@dev-proxy.wzu.io:3128
export https_proxy=http://ue73011:secret@dev-proxy.wzu.io:3128

不幸的是,这并没有改变任何东西。

任何想法为什么这不起作用?

【问题讨论】:

    标签: docker openshift dockerhub


    【解决方案1】:

    您的 docker 守护程序需要代理才能访问 DockerHub。您可以通过将代理服务器作为 docker 守护进程的环境变量来指定代理服务器。

    查看官方 Docker 文档:https://docs.docker.com/config/daemon/systemd/

    sudo mkdir -p /etc/systemd/system/docker.service.d
    

    添加一个文件/etc/systemd/system/docker.service.d/http-proxy.conf,其中应包含以下内容

    [Service]    
    Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"
    

    重新加载您的更改并重新启动 docker daemon

    sudo systemctl daemon-reload
    sudo systemctl restart docker
    

    通过简单的“docker pull ...”进行验证

    【讨论】:

    • 如果我猜对了,我必须在 openshift 服务器上执行此操作吗?不幸的是,除了 openshift Web UI 或 openshift 客户端之外,我无法访问这台机器。
    • 不幸的是,“oc new-app”(恕我直言)不接受任何代理设置。代理设置需要在“new-app”实际运行的环境中设置。也许您可以将映像推送到 OpenShift 可用的某个注册表(即内部注册表)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-02
    • 1970-01-01
    • 1970-01-01
    • 2014-08-27
    • 1970-01-01
    相关资源
    最近更新 更多