问题描述
我已将这个代码从似乎是各种工作的dockerfiles复制到这里,这里是我的:
I have copied this code from what seems to be various working dockerfiles around, here is mine:
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,但是从我读过的(并从工作配置)我不明白为什么这不工作。
This is my first time using dockerfiles, but from what I have read (and taken from working configs) I cannot see why this doesn't work.
我的id_rsa与我的dockerfile在同一个文件夹中,是我的本地密钥的副本,可以克隆这个回复没有问题。
My id_rsa is in the same folder as my dockerfile and is a copy of my local key which can clone this repo no problem.
编辑:
在我的docker文件中,我可以添加:
In my dockerfile I can add:
RUN cat /root/.ssh/id_rsa
它打印出正确的键,所以我知道它被正确复制。
And it prints out the correct key, so I know its being copied correctly.
我也试图做为noah建议和运行: p>
I have also tried to do as noah advised and ran:
RUN echo "Host bitbucket.org\n\tIdentityFile /root/.ssh/id_rsa\n\tStrictHostKeyChecking no" >> /etc/ssh/ssh_config
这不幸也不行。
推荐答案
我的密钥受到密码保护,导致问题,下面列出了一个工作文件(为将来的Google员工提供帮助)
My key was password protected which was causing the problem, a working file is now listed below (for help of future googlers)
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
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
这篇关于克隆与docker文件的私人git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!