title: Automated pulling from gitolite repo within docker container
body: <pre><code>FROM fedora:latest
  
  RUN yum install -y nginx git uwsgi
  
  RUN echo "nameserver 8.8.4.4" &gt; /etc/resolv.conf
  RUN rm -rf /root/.ssh/ &amp;&amp; mkdir -p /root/.ssh/
  COPY id_rsa.pub /root/.ssh/id_rsa.pub
  COPY id_rsa /root/.ssh/id_rsa
  RUN cat /root/.ssh/id_rsa* &amp;&amp; chmod 0400 /root/.ssh/id_rsa &amp;&amp; echo "" &gt; /root/.ssh/known_hosts
  
  RUN mkdir -p /srv/nginx/
  RUN ssh -vvv -p 49022 git@example.com || true
  
  RUN git config --global user.email "somethingelse@example.com" &amp;&amp; git config --global user.name "FunnyBunny"
  RUN git clone --depth=1 ssh://git@example.com:port/repo.git /srv/nginx/repo
  RUN chown -Rf nginx:nginx /srv/nginx
  
  RUN rm -rf /root/.ssh/
  
  
  USER nginx
  
  
  EXPOSE 8080
  
  
  CMD ["/usr/sbin/nginx"]
  </code></pre>
  
  <p>I added the public ssh <code>id_rsa.pub</code> to my gitolite repo on the same host in another docker container. The bad thing is that cloning always fails.</p>
  
  <pre><code>Cloning into '/srv/nginx/repo'...
  Host key verification failed.
  fatal: Could not read from remote repository.
  
  Please make sure you have the correct access rights
  and the repository exists.
  </code></pre>
  
  <p>while the ping works just fine.</p>
  
  <p>The <code>ssh -vvv</code> line ends with</p>
  
  <pre><code>Host key verification failed.
  </code></pre>
  
  <hr>
  
  <p>On the other hand-side, importing public and private keys into a <code>fedora:latest</code> and running just a <code>git clone --depth ...</code>, <strong>just works</strong>!.</p>
  
  <hr>
  
  <p>I am really puzzled how to fix this issue.</p>
  
  <p>CoreOS version 557.2.0</p>
  
  <hr>
  
  <p>This does not yield a viable solution: <a href="https://stackoverflow.com/questions/18136389/using-ssh-keys-inside-docker-container">Using SSH keys inside docker container</a></p>