如何从docker hub部署到openshift?

时间:2019-05-09 11:23:15

标签: docker openshift dockerhub

我正在尝试在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

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

有什么想法为什么不起作用?

1 个答案:

答案 0 :(得分: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 ...”进行验证