【发布时间】:2019-11-27 02:34:52
【问题描述】:
我有一个 Docker 容器,它正在启动一个项目,该项目在私有仓库中具有依赖项。
Dockerfile 正在复制我的无密码 SSH 密钥(权限为 600 和 644):
COPY docker/config/id_rsa /root/.ssh/
COPY docker/config/id_rsa.pub /root/.ssh/
复制后,Composer 依赖项正在安装:
RUN echo *** >> /etc/hosts \
&& composer config -a -g *URL *USER *PASS \
&& composer install --prefer-dist --no-progress
同时,我删除了composer.lock,以确保之前的安装没有留下任何东西。
composer 的存储库部分如下所示:
"repositories": [
{
"type": "vcs",
"url": "git@***:***/libs/***.git",
"options": {
"ssl": {
"local_cert": "~/.ssh/id_rsa.pub"
}
}
},
],
在创建容器期间,我收到一条错误消息:
[RuntimeException]
Failed to execute git clone --mirror 'git@***:***/libs/***.git' '/root/.composer/cache/vcs/.../'
Cloning into bare repository '/root/.composer/cache/vcs/...'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
存储库确实存在,SSH 密钥是有效的,而且最奇怪的是...如果我省略 composer install 命令并进入创建的容器,什么都不做更改并从终端手动执行,它会安装所有内容。
编辑:
我还尝试在 RUN 命令中手动编写密钥,如果在任何情况下它们在容器创建期间不可用,但这没有帮助。
我也尝试过从 Composer 中删除 "options" 部分
【问题讨论】:
-
id_rsa.pem是如何生成的?您只复制id_rsa和id_rsa.pub -
对不起,应该是
id_rsa.pub。它是使用 ssh keygen 生成的。两者都被复制
标签: git docker ssl ssh composer-php