我使用coding.net创建了私有存储库
我使用docker images alpine 和 centos
我可以从docker-centos获取git.coding.net/alphayan/orionv2.git successful
,但我无法从docker-alpine获取git.coding.net/alphayan/test.git
。它会返回错误说明:
/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的版本引起的,带有git 1.8.3的centos和带有git 2.11.0的alpine引起的。
然后我用2.11.0改变了centos git的版本,与alpine相同的错误。
我想我可以修改golang或git源文件来解决这个问题,
有人能帮助我吗?认为〜!
答案 0 :(得分:3)
发生此错误的原因是默认情况下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)中表现不同的原因。
您可以通过git >= 2.3
运行go get
,按照以下方式解决问题:
$ 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':
答案 1 :(得分:1)
如果您的public ssh key is registered on coding.net。
,您可以尝试使用ssh请参阅“go get for private repos in docker”作为示例:
<template match="child::Primary_Key/following-sibling::*"/>
使用构建步骤:
FROM golang:1.6
RUN echo "[url \"git@github.com:\"]\n\tinsteadOf = https://github.com/" >> /root/.gitconfig
RUN mkdir /root/.ssh && echo "StrictHostKeyChecking no " > /root/.ssh/config
ADD . /go/src/github.com/company/foo
CMD cd /go/src/github.com/company/foo && go get github.com/company/bar && go build -o /foo