Jon*_*inh 0 git ssh ssh-agent docker
我正在尝试在构建过程中向ssh-agent(docker映像)添加本地私钥。
问题
我已经运行, eval$(ssh-agent -s)并且一旦docker运行,ssh-add /etc/ssh/id_rsa我会收到以下错误:
Could not open a connection to your authentication agent.
目标:我需要在NPM安装过程中克隆一个私有git repo。此本地密钥将允许我针对私人存储库进行身份验证。
====输出片段====
Step 8/16 : RUN eval $(ssh-agent -s)
---> Running in 195ffeb1f84f
Agent pid 8
---> 0fcbc89d362f
Removing intermediate container 195ffeb1f84f
Step 9/16 : RUN ssh-add /etc/ssh/id_rsa
---> Running in ae99039e1fba
Could not open a connection to your authentication agent.
The command '/bin/sh -c ssh-add /etc/ssh/id_rsa' returned a non-zero code: 2
Run Code Online (Sandbox Code Playgroud)
在步骤9中,您在步骤8中运行的代理已失效。您需要一次性执行或执行所有步骤,此功能才能起作用。
RUN eval $(ssh-agent -s) && ssh-add /etc/ssh/id_rsa && git checkout .....
Run Code Online (Sandbox Code Playgroud)