我正在尝试从github克隆私有git存储库。我做了一个这样的Dockerfile:
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y git
RUN mkdir -p /root/.ssh/
ADD ./id_rsa /root/.ssh/id_rsa
RUN git clone git@github.com:usr/repo.git
我在本地很好地使用了这个repo和这个键,所以看起来我在docker中遗漏了一些东西。
我可能遗漏的另一件事是,docker中的~
和$HOME
都指向/
而不是/root
,但我不确定这是否相关。
发布于 2013-10-29 05:57:42
构建过程的输出是什么?
随机猜测:尝试chmod 600
私钥。
如果仍然不起作用,请尝试RUN ssh -v git@github.com
(在添加密钥之后);输出应该会解释发生了什么。
发布于 2014-11-19 13:00:40
运行ssh-keyscan github.com >> ~/.ssh/known_hosts
keyscan工作得很好,因为它接受主机。下面的完整答案起作用了:
RUN mkdir -p /root/.ssh
RUN cp /var/my-app/id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
同样如前所述:
RUN ssh -v git@github.com
^调试流程的好方法。这就是我意识到我需要键盘扫描>> known_hosts的原因
发布于 2019-12-24 19:00:51
下面的方法是在Personal Access Token中使用https
,它的工作方式很有魅力。
ARG git_personal_token
RUN git config --global url."https://${git_personal_token}:@github.com/".insteadOf "https://github.com/"
RUN git clone https://github.com/your/project.git /project
然后,提供一个docker参数,如下所示。
docker build --build-arg git_personal_token={your_token} .
基本思想来自https://medium.com/paperchain/fetching-private-github-repos-from-a-docker-container-273f25ec5a74
https://stackoverflow.com/questions/19643946
复制相似问题