【问题标题】:Composer in Docker not passing verification for private repo [duplicate]Docker 中的 Composer 未通过私有仓库的验证 [重复]
【发布时间】:2019-11-27 02:34:52
【问题描述】:

我有一个 Docker 容器,它正在启动一个项目,该项目在私有仓库中具有依赖项。

Dockerfile 正在复制我的无密码 SSH 密钥(权限为 600644):

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_rsaid_rsa.pub
  • 对不起,应该是id_rsa.pub。它是使用 ssh keygen 生成的。两者都被复制

标签: git docker ssl ssh composer-php


【解决方案1】:

RUN 命令中缺少这些部分:

echo "xxx.xxx.xxx.xxx my_server_name" >> /etc/hosts

ssh-keyscan -t rsa my_server_name >> ~/.ssh/known_hosts 

完成后,我可以从 Composer 中完全省略 "options" 部分

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 2018-04-29
    • 2016-06-14
    相关资源
    最近更新 更多