无法使用dockerfile克隆私人回购

我是docker工人,所以尝试所有基本的东西。

我已经使用以下dockerfile来生成我的工作泊坞窗图像

FROM ubuntu:14.04 MAINTAINER Alok Agarwal "alok.alok.com" RUN apt-get update #Install git RUN apt-get install -y git RUN mkdir -p /root/.ssh/ ADD id_rsa /root/.ssh/id_rsa RUN touch /root/.ssh/known_hosts RUN chmod 700 /root/.ssh/id_rsa RUN git clone git@github.com:user/user.git EXPOSE 80 

我能够使用ssh在我的本地系统中克隆我的回购,但是从docker那里得到回报

 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

我已经把我的id_rsa文件放在我的dockerfile所在的地方,但仍然不知道为什么它连续失败。

我是否缺less任何基本步骤?

提前感谢您的时间

看看我的例子,我有一个私人的 ssh密钥在我dockerize应用程序( ssh_keys/id_rsa ),我已经上传到私人回购的公共密钥:

 FROM ubuntu:14.04 MAINTAINER Alok Agarwal "alok.alok.com" RUN apt-get update #Install git RUN apt-get install -y git RUN /bin/bash -l -c "mkdir /root/.ssh" ADD ssh_keys/id_rsa /root/.ssh/id_rsa RUN chmod 700 /root/.ssh/id_rsa RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config RUN mkdir -p /www/app RUN git clone git@github.com:my_private_repo/repo.git /www/app 

有几种方法可以运行git clone ,你失败的方式是通过ssh,但是在容器中,你没有上传合适的私有ssh密钥到git hub,所以github拒绝了这个请求。 哟可以使用https链接git clone

 RUN git clone https://github.com/user/user.git