openshift - Openshift new-app 不适用于 dockerfile
问题描述
我正在尝试使用 CLI 在 Openshift 中部署新应用程序。当我使用 GUI 并单击“从 docker 文件构建”时,一切正常。但是当我使用 CLI 时,它不会。
这些是我的仓库中的文件:
Dockerfile
FROM golang:1.11-alpine
RUN mkdir /app
COPY main.go /app
WORKDIR /app
RUN go build -o main .
EXPOSE 8080 8888
USER 1001
ENTRYPOINT ["/app/main"]
main.go
package main
import (
"fmt"
"net/http"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "<h1>Hello OpenShift! Updated build</h1>")
}
func listenAndServe(port string) {
fmt.Printf("serving on %s\n", port)
err := http.ListenAndServe(":"+port, nil)
if err != nil {
panic("ListenAndServe: " + err.Error())
}
}
func main() {
http.HandleFunc("/", helloHandler)
go listenAndServe("8080")
select {}
}
我正在关注这篇文章。我已将文件复制到我的私人仓库并使用源密码进行克隆。就像那里提到的那样,我使用了这个命令和 source-secret
oc new-app https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development --source-secret=my-secret --name=demo-blah
这给了我以下错误
error: unable to load template file "https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development": error parsing https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development: error converting YAML to JSON: yaml: line 3: mapping values are not allowed in this context
error: git ls-remote failed with: fatal: unable to access 'https://git.abcd.corp.mycompany.com/12345/openshift-trail.git/': Problem with the SSL CA cert (path? access rights?); local file access failed with: stat https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development: no such file or directory
error: unable to locate any images in image streams, templates loaded in accessible projects, template files, local docker images with name "https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development"
Argument 'https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development' was classified as an image, image~source, or loaded template reference.
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.
根据openshift doco,它说如果 repo 中有 Dockerfile,它应该自动检测它。但是在这里我遇到了一个我无法理解的奇怪错误。任何帮助深表感谢。
解决方案
You could just build it as a regular dockerfile on your own computer and upload it to a Docker registry and then deploy it to openshift from the remote registry or you could even push it to the built in registry on openshift.
I think the command you are looking for is probably
oc new-build
This article might help:
https://dzone.com/articles/4-ways-to-build-applications-in-openshift-1
推荐阅读
- c# - SerialDataReceived 事件未触发(Arduino 克隆的串行端口设置)
- javascript - 有 setClientBoundingRect() 吗?
- python - for 循环中的子图
- java - 使用特定的 application.properties 自动装配
- tensorflow - 提供 Tensorflow Seq2Seq 输出作为下一步的输入(推理)
- python - 从帧中检测到目标和非目标对象后,将具有目标对象的图像从 1 个文件夹保存到另一个文件夹
- php - .htaccess 代码显示 500 内部错误
- r - 在R中,跨两个数据帧匹配来自字符串变量的数据,当找到匹配时,合并相应的行
- java - 有没有办法根据参数的值使 MySQL 查询行为不同?
- c# - 如何通过单击按钮将特定文件夹复制到新文件夹