Dockerfile can't find my private ssh key

I’m trying to build a dockerfile so that it clones a private repo. I’ve believe I’ve added the right code to do this, but it keeps throwing this error:

build: id_rsa: no such file or directory

I’ve made sure the path is right and that the key is in there, and tried numerous other solutions proposed on here such as uncommenting the IdentityFile in ssh_config to no avail. Here is my dockerfile:

  • Problems with Sailsjs application in Docker container
  • run netflixoss docker on windows 8.1
  • How to Access Windows Container from a Remote Host using Docker command line tool
  • Is it safe to extract the root filesystem of a image and use it in a chroot?
  • Create a kubernetes namespace using config instead of API
  • UDP packets aren't forwarded to Node Application inside of docker container
  • FROM ubuntu:latest
    MAINTAINER John Fink <>
    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
    ADD ./ /
    ADD ./ /etc/apache2/
    ADD ./supervisord.conf /etc/supervisord.conf
    RUN chmod 755 /
    RUN chmod 755 /etc/apache2/
    EXPOSE 80
    CMD ["/bin/bash", "/"]

  • difference between docker attach and docker exec
  • Error response from daemon: network myapp not found
  • I want to create a Docker image which contains Java and PostgreSQL. I just want to create an Image to reuse it from anywhere
  • Unable to login to private docker registry
  • Creating a cassandra docker image with initialized KEYSPACE and schema
  • How to setup group of docker containers with the same addresses?
  • 2 Solutions collect form web for “Dockerfile can't find my private ssh key”

    Is your id_rsa file in the current directory where your Dockerfile is? Try specifying the full path to it

    I did a more brute force version to see, and

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

    fails hard –

    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@
    Bad owner or permissions on /root/.ssh/config
    root@810a2b43ed12:/# chown -R root:root /root/.ssh/
    root@810a2b43ed12:/# ssh sven@
    Linux mini 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

    so I’d say you just need to do a

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

    and you should be good to go.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.