我已经从似乎各种各样的工作dockerfile中复制了此代码,这是我的:
FROM ubuntu MAINTAINER Luke Crooks "luke@pumalo.org" # Update aptitude with new repo RUN apt-get update # Install software RUN apt-get install -y git python-virtualenv # Make ssh dir RUN mkdir /root/.ssh/ # Copy over private key, and set permissions ADD id_rsa /root/.ssh/id_rsa RUN chmod 700 /root/.ssh/id_rsa RUN chown -R root:root /root/.ssh # Create known_hosts RUN touch /root/.ssh/known_hosts # Remove host checking RUN echo "Host bitbucket.org\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config # Clone the conf files into the docker container RUN git clone git@bitbucket.org:Pumalo/docker-conf.git /home/docker-conf
这给我错误
Step 10 : RUN git clone git@bitbucket.org:Pumalo/docker-conf.git /home/docker-conf ---> Running in 0d244d812a54 Cloning into '/home/docker-conf'... Warning: Permanently added 'bitbucket.org,131.103.20.167' (RSA) 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. 2014/04/30 16:07:28 The command [/bin/sh -c git clone git@bitbucket.org:Pumalo/docker-conf.git /home/docker-conf] returned a non-zero code: 128
这是我第一次使用dockerfiles,但是从我阅读的内容(以及从有效的配置中获取)来看,我不明白为什么它不起作用。
我的id_rsa与我的dockerfile位于同一文件夹中,并且是我的本地密钥的副本,可以克隆此存储库。
编辑:
在我的dockerfile中,我可以添加:
RUN cat /root/.ssh/id_rsa
并且它会打印出正确的密钥,因此我知道它已正确复制。
我还尝试按照诺亚的建议去做:
RUN echo "Host bitbucket.org\n\tIdentityFile /root/.ssh/id_rsa\n\tStrictHostKeyChecking no" >> /etc/ssh/ssh_config
可悲的是这也行不通。
我的密钥受到密码保护,这是导致问题的原因,下面列出了一个工作文件(以帮助将来的Google员工)
FROM ubuntu MAINTAINER Luke Crooks "luke@pumalo.org" # 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 # Warning! Anyone who gets their hands on this image will be able # to retrieve this private key file from the corresponding image layer 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 # Clone the conf files into the docker container RUN git clone git@bitbucket.org:User/repo.git