Docker 容器构建时出现 "fatal: could not read Username for 'https://github.com'" 错误,如何解决?
常见 docker 构建错误及解决方案
在执行 go build 时构建 docker 容器时,你可能会遇到以下错误:
answer imports github.com/answerdev/answer-basic-connector: module github.com/answerdev/answer-basic-connector: git ls-remote -q origin in /go/pkg/mod/cache/vcs/2eb01f4aadbb28882970063faa18a6e807b04bd4da767dddd04d856f1fa4e95b: exit status 128: fatal: could not read username for 'https://github.com': terminal prompts disabled confirm the import path was entered correctly. if this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
解决方案:
此错误表示 go 无法获取 github 用户名,因为终端提示被禁用。要解决此问题,请执行以下步骤:
- 增加 git 环境变量:
export GIT_TERMINAL_PROMPT=1
- 再次执行 go build。它将提示你输入 github 仓库的登录密码进行验证。输入后即可完成构建。
以上就是Docker 容器构建时出现 "fatal: could not read Username for 'https://github.com'" 错误,如何解决?的详细内容,更多请关注硕下网其它相关文章!