dou760663
2017-02-23 03:27
采纳率: 100%
浏览 187

Docker Alpine Golang Go进入coding.net私有仓库错误

I created the private repository using the coding.net.
I use docker images alpine and centos.
I can go get git.coding.net/alphayan/orionv2.git successful from docker-centos, but I can't go get git.coding.net/alphayan/test.git from docker-alpine.It returns an error stating:

/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

From centos it let me use the username and password:

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

finally, I find it caused by the git's version, the centos with git 1.8.3 and the alpine with git 2.11.0.
then I change the centos git's version with 2.11.0, becomes the same wrong with alpine. I think I can modify golang or git source file solve this problem, could someone help me? thinks~!

图片转代码服务由CSDN问答提供 功能建议

我使用encoding.net创建了私有存储库。
我使用docker镜像 alpine < / strong>和 centos
我可以从docker-centos成功获得 git.coding.net/alphayan/orionv2.git ,但是我不能 从docker-alpine获取 git.coding.net/alphayan/test.git 。它会返回错误,指出:

  / go / src# 去得到-u -v git.coding.net/alphayan/test.git
# cd。  git ls-remote https://git.coding.net/alphayan/test
fatal:无法读取“ https://git.coding.net”的用户名:终端提示禁用
#cd。  git ls-remote git + ssh://git.coding.net/alphayan/test 
权限被拒绝(公钥)。
fatal:无法从远程存储库读取。
 
请确保您具有正确的访问权限
  
#cd。  git ls-remote ssh://git.coding.net/alphayan/test 
权限被拒绝(公钥)。
fatal:无法从远程存储库读取。
 
请确保您具有正确的访问权限
和存储库 
包git.coding.net/alphayan/test.git:无法下载,git.coding.net/alphayan/test使用不安全的协议
   
 
 

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

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

最后,我发现它是由git的版本,带有git 1.8.3的centos和阿尔卑斯山脉引起的 git 2.11.0。
t当我将2.1os的centos git版本更改为alpine时,也会出现相同的错误。 我认为我可以修改golang或git源文件来解决此问题, 有人可以帮助我吗? 想〜!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongping1922 2017-05-26 18:09
    已采纳

    This error happens because by default go get doesn't use terminal input. This behaviour can be changed by modifying environment variable GIT_TERMINAL_PROMPT, which was introduced in git 2.3. That's why the go get command behaves differently in CentOS 7 (git 1.8) and Alpine 3.5 (git 2.11).

    You can work your way around the issue in git >= 2.3 by running go get as follows:

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

    If you have multiple go get calls then you can export that environment variable before running the commands:

    $ 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':
    
    打赏 评论
  • douweiduo7526 2017-02-23 05:58

    You could try through ssh, if your public ssh key is registered on coding.net.

    See "go get for private repos in docker" as an example:

    FROM golang:1.6
    
    RUN echo "[url \"git@github.com:\"]
    \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
    

    with the build step:

    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 
    
    打赏 评论

相关推荐 更多相似问题