git - Docker alpine golang go get error for coding.net private repo

标签 git go docker

我使用 coding.net 创建了私有(private)存储库。
我使用 docker images alpinecentos
我可以从 docker-centos 获取 git.coding.net/alphayan/orionv2.git successful,但我无法获取 git.coding.net/alphayan/test.git 来自 docker-alpine。它返回一个错误说明:

/go/src # go get -u -v  git.coding.net/alphayan/test.git
# cd .; git ls-remote https://git.coding.net/alphayan/test
fatal: could not read Username for 'https://git.coding.net': terminal prompts disabled
# cd .; git ls-remote git+ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
package git.coding.net/alphayan/test.git: cannot download, git.coding.net/alphayan/test uses insecure protocol

从centos它让我使用用户名和密码:

[root@83fc8067fc95 /]# go get -u -v git.coding.net/alphayan/test.git
Username for 'https://git.coding.net':

最后发现是git的版本问题,centos是git 1.8.3,alpine是git 2.11.0。
然后我将centos git的版本更改为2.11.0,变得与alpine一样错误。 我想我可以修改 golang 或 git 源文件来解决这个问题, 有人可以帮助我吗?想~!

最佳答案

发生此错误是因为默认情况下 go get doesn't use terminal input .可以通过修改 git 2.3 中引入的环境变量 GIT_TERMINAL_PROMPT 来更改此行为。这就是 go get 命令在 CentOS 7 (git 1.8) 和 Alpine 3.5 (git 2.11) 中表现不同的原因。

您可以通过运行 go get 解决 git >= 2.3 中的问题,如下所示:

$ GIT_TERMINAL_PROMPT=1 go get github.com/foo/bar
Username for 'https://github.com':

如果您有多个 go get 调用,那么您可以在运行命令之前导出该环境变量:

$ export GIT_TERMINAL_PROMPT=1
$ go get github.com/foo/bar
Username for 'https://github.com':
$ go get github.com/foo/baz
Username for 'https://github.com':

关于git - Docker alpine golang go get error for coding.net private repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42406445/

相关文章:

git gitolite (v3) 预接收所有提交消息的钩子(Hook)

macos - 将变量传递给 git filter-branch 中的命令(通过删除旧二进制文件来减少存储库大小时)

go - 为 3rdparty/go/golang.org/x/text :* 定义 go_remote_library 声明时出现问题

docker - 如何访问特定 gitlab-runner 在 CI 测试中制作的屏幕截图

git - TeamCity 中功能分支的自动 merge 不起作用

带有个人访问 token 的 Jenkins 中的 Git 克隆永远闲置

go tool pprof 使用应用程序 PID 而不是 http 端点

go - Windows 上的 InfluxDB 安装问题

docker - Jmeter 和 Docker

docker - Mesos和Marathon关于Docker的局限性