2014-02-19 41 views
3

我正在嘗試構建一個dockerfile,以便它克隆私人回購。我一直相信,我已經添加了正確的代碼要做到這一點,但它不斷拋出這個錯誤:Dockerfile無法找到我的私人ssh密鑰

build: id_rsa: no such file or directory 

我做了一定的路徑是正確的,關鍵是在那裏,並試圖許多其他在這裏提出的解決方案,例如取消註釋ssh_config中的IdentityFile無濟於事。這裏是我的dockerfile:

FROM ubuntu:latest 
MAINTAINER John Fink <[email protected]> 
RUN apt-get update # Thu Nov 7 22:40:44 EST 2013 


RUN apt-get install -y mysql-client mysql-server apache2 libapache2-mod-php5 pwgen  python-setuptools vim-tiny php5-mysql git 

RUN easy_install supervisor 

ADD id_rsa /root/.ssh/id_rsa 
ADD known_hosts /root/.ssh/known_hosts 
RUN echo " IdentityFile /root/.ssh/id_rsa" >> /etc/ssh/ssh_config 

RUN cd /var/www 
RUN git clone [email protected]:eric/hartshorn-portraiture.git 

ADD ./start.sh /start.sh 
ADD ./foreground.sh /etc/apache2/foreground.sh 
ADD ./supervisord.conf /etc/supervisord.conf 
RUN chmod 755 /start.sh 
RUN chmod 755 /etc/apache2/foreground.sh 
EXPOSE 80 
CMD ["/bin/bash", "/start.sh"] 
+1

你知道'/ root/.ssh'目錄存在於'ADD id_rsa/root/.ssh/id_rsa'行之前嗎? –

回答

4

您的id_rsa文件位於您的Dockerfile所在的當前目錄中嗎?嘗試指定它的完整路徑

+0

我是個白癡,我以爲「root」是指我的電腦的根,而不是Dockerfile的。謝謝 – prospekt

1

我做了一個更強力的版本看,和

FROM ubuntu 
RUN apt-get -yq install ssh 
ADD .ssh /root/.ssh/ 
CMD  bash 

失敗硬 -

[email protected]:~/src/docker/tmp$ docker run -rm -t -i test 
[email protected]:/# ls -la /root 
total 20 
drwx------ 3 root root 4096 Feb 20 04:12 . 
drwxr-xr-x 45 root root 4096 Feb 20 04:17 .. 
-rw-r--r-- 1 root root 3106 Apr 19 2012 .bashrc 
-rw-r--r-- 1 root root 140 Apr 19 2012 .profile 
drwx------ 2 1000 1000 4096 Feb 20 04:04 .ssh 
[email protected]:/# ssh [email protected] 
Bad owner or permissions on /root/.ssh/config 
[email protected]:/# chown -R root:root /root/.ssh/ 
[email protected]:/# ssh [email protected] 
Linux mini 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 

所以我說,你只需要做a

RUN chown -R root:root /root/.ssh 

你應該很好走。