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"]
我将公共ssh id_rsa.pub
添加到我在另一个docker容器中的同一主机上的gitolite repo上。坏事是克隆总是失败。
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.
虽然ping工作正常。
ssh -vvv
行以
Host key verification failed.
另一方面,将公钥和私钥导入fedora:latest
并仅运行git clone --depth ...
,正常运作!。
我真的很困惑如何解决这个问题。
CoreOS版本557.2.0
这不会产生可行的解决方案:Using SSH keys inside docker container
答案 0 :(得分:0)
由于CoreOS需要设置 StrictHostKeyChecking = false ,因此您可以在 git clone 命令前加上:
GIT_SSH='ssh -o StrictHostKeyChecking=false'
强制选择。