2017-03-10 45 views
0

I'm做碼頭工人,文件用下面的代碼:bitbucket docker權限被拒絕(publickey)。致命的:無法從遠程存儲庫中讀取

# Update aptitude with new repo 
RUN apt-get update 

# Install software 
RUN apt-get install -y git 
# Make ssh dir 
RUN mkdir /root/.ssh/ 

# Copy over private key, and set permissions 
ADD id_rsa /root/.ssh/id_rsa 

# Create known_hosts 
RUN touch /root/.ssh/known_hosts 
# Add bitbuckets key 
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts 

RUN chgrp 545 ~/.ssh/id_rsa 
RUN chmod 600 ~/.ssh/id_rsa 

# Clone the conf files into the docker container 

RUN git clone [email protected]:xxxxxx/teste.git 

RUN cd teste echo "# My project's README" >> README.md 
RUN git add README.md 
RUN git commit -m "Initial commit" 
RUN git push -u origin master 

但是,當我建我得到了以下錯誤的文件:

Cloning into 'teste'... Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.x' to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. The command '/bin/sh -c git clone [email protected]:xxxxxxxx/teste.git' returned a non-zero code: 128

我產生帶有PuTTY密鑰的id_rsa,並已存儲在bitbucket中。

任何人都可以幫忙嗎?

+0

可以粘貼整個Dockerfile好嗎? – johnharris85

+0

It's完整的文件,它只是有一個從Ubuntu的:16.04在它的頂部。 –

+0

這就是我想知道的:) – johnharris85

回答

0

我相信你需要添加相應的私鑰容器也。由於您提到您使用putty生成了id_rsa密鑰,因此該密鑰位於主機中。

你需要的是添加id_rsa鑰匙在你的容器和id_rsa.pub的到位桶。

This後可能會幫助你。

相關問題