Dockerfile cannot find my ssh private key

I am trying to create a docker file so that it clones a private repo. I believe that I have added the correct code for this, but it continues to throw this error:

build: id_rsa: no such file or directory

I made sure that the path is correct and that the key is there, and tried many other solutions offered here, for example, uncommenting IdentityFile in ssh_config to no avail. Here is my docker file:

FROM ubuntu:latest
MAINTAINER John Fink <john.fink@gmail.com>
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 git@dev.ploonky.com: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"]
+3
source share
2 answers

Is your file id_rsain the current directory where your Docker file is? Try to indicate the full path to it.

+4
source

I made a rougher version to view, and

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

fails -

sven@mini:~/src/docker/tmp$ docker run -rm -t -i test 
root@810a2b43ed12:/# 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
root@810a2b43ed12:/# ssh sven@192.168.1.220
Bad owner or permissions on /root/.ssh/config
root@810a2b43ed12:/# chown -R root:root /root/.ssh/
root@810a2b43ed12:/# ssh sven@192.168.1.220
Linux mini 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

so I would say that you just need to do

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

and you should be good to go.

+1

All Articles