【问题标题】:Automated pulling from gitolite repo within docker container从 docker 容器中的 gitolite repo 自动拉取
【发布时间】:2015-02-22 09:55:40
【问题描述】:
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 存储库中。不好的是克隆总是失败。

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

【问题讨论】:

  • “我将公共 ssh id_rsa 添加到我的 gitolite 存储库中”:您的意思是 id_rsa.pub 吗?因为.pub 是公钥。当你把它放在gitolite/keys folder 中时,你给它取了什么名字id_rsa.pub
  • Ye pub ofc,相应地解决了这个问题。公钥在 gitolite 中的名称根本不重要,如果我错了,请纠正我。
  • 公钥的名称(如gitolite/keys 中所写)至关重要:请参阅我的旧答案stackoverflow.com/a/13320256/6309 和官方文档gitolite.com/gitolite/…
  • 是否需要在 CoreOS 上禁用 StrictHostKeyChecking ?
  • @VonC 只要 pubkey 名称和配置一致(在我的情况下两者都称为“puller”)gitolite 应该可以正常工作,无论使用什么 git 用户名。

标签: git ssh docker gitolite


【解决方案1】:

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

GIT_SSH='ssh -o StrictHostKeyChecking=false'

强制选项。

【讨论】:

  • 这并没有解释手动和构建 git clone 之间的区别。
  • 环境(如 env 命令所示)在从 Dockerfile 运行和从解释行为变化的容器运行时很可能会显示出差异。跨度>
猜你喜欢
  • 2018-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 2017-03-10
  • 1970-01-01
相关资源
最近更新 更多