docker集装箱内的gitolite回购自动拉

FROM fedora:latest RUN yum install -y nginx git uwsgi RUN echo "nameserver 8.8.4.4" > /etc/resolv.conf RUN rm -rf /root/.ssh/ && 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* && chmod 0400 /root/.ssh/id_rsa && echo "" > /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" && 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"] 

我在另一个docker集装箱的同一台主机上添加了公共的ssh id_rsa.pub到我的gitolite仓库。 坏事是克隆总是失败。

 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. 

而平能工作得很好。

ssh -vvv行以

 Host key verification failed. 

另一方面,将公钥和私钥导入到fedora:latest并运行一个git clone --depth ...正常工作


我真的很困惑如何解决这个问题。

CoreOS版本557.2.0


这不会产生可行的解决scheme: 在Docker容器中使用SSH密钥

由于看起来像CoreOS要求设置StrictHostKeyChecking = false ,所以可以在git clone命令前加上:

 GIT_SSH='ssh -o StrictHostKeyChecking=false' 

强制选项。