docker高山golang去编码.net私人回购得到错误
我使用coding.net创build了私有存储库。
我使用docker图像高山和centos 。
我可以从git.coding.net/alphayan/orionv2.git successful
-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的版本,与高山变成了一样的错误。 我想我可以修改golang或git源文件解决这个问题,有人可以帮我吗? 认为〜!
发生这个错误是因为默认情况下go get
不使用terminalinput 。 这个行为可以通过修改git 2.3中引入的环境variablesGIT_TERMINAL_PROMPT
来改变。 这就是为什么go get
命令在CentOS 7(git 1.8)和Alpine 3.5(git 2.11)中performance不同的原因。
你可以通过运行git >= 2.3
来解决这个问题go get
如下:
$ GIT_TERMINAL_PROMPT=1 go get github.com/foo/bar Username for 'https://github.com':
如果你有多个go get
打电话,那么你可以在运行命令之前导出这个环境variables:
$ 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':
你可以通过ssh尝试,如果你的公共ssh密钥在coding.net上注册的话 。
例如,请参阅“ 在Docker中获取私人回购 ”
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
与构build步骤:
docker build -t foo-build . docker run --name=foo-build -v ~/.ssh/id_rsa:/root/.ssh/id_rsa foo-build docker cp foo-build:/foo foo docker rm -f foo-build docker rmi -f foo-build