我想在从Dockerfile构建图像时克隆存储库。我使用的sequenceiq/docker-spark Dockerfile和如下(前ENTRYPOINT
线)延长它:我得到了几分钟后,下面的错误Dockerfile中的Git克隆回购
RUN yum install -y git
RUN git clone [email protected]:myorg/myrepo.git
:
Initialized empty Git repository in /myrepo/.git/
fatal: The remote end hung up unexpectedly
INFO[0128] The command [/bin/sh -c git clone [email protected]:myorg/myrepo.git] returned a non-zero code: 128
我已经添加了图像的id_rsa.pub
到该存储库的部署密钥。我尝试在图像上运行bash
,并尝试运行git clone
,同样的问题。我很难过。我发现这个相关的问题here,但我的SSH密钥是无密码的,所以它没有帮助。
基本映像生成一个无密码的私人公钥对。我将该公钥从映像添加到存储库的部署密钥中,因此相应的私钥在'/ root/.ssh/id_rsa'中可用。而且,如果我不添加公钥,我会得到同样的错误。 –