docker - git@gitlab.com:权限被拒绝 - 致命:无法从 Dockerfile 读取远程存储库
问题描述
我有Dockerfile
以下RUN
说明:
RUN pip install -r ./private_requirements.txt
该private_requirements.txt
文件是一个指向 GitLab 存储库的 ssh URL:
git+ssh://git@gitlab.com/organization/viiaa/abc_xx.git@v19.0
当我docker build
评估 RUN 指令时,我得到以下输出:
> [intermediate 9/9] RUN pip install git+ssh://git@gitlab.com/organization/viiaa/abc_xx.git@v19.0:
#13 0.574 Collecting git+ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0
#13 0.574 Cloning ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0 (to revision v19.0) to /tmp/pip-req-build-ck2o3z6p
#13 0.574 Running command git clone -q 'ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0' /tmp/pip-req-build-ck2o3z6p
#13 1.018 Warning: Permanently added the ECDSA host key for IP address '172.65.251.78' to the list of known hosts.
#13 1.286 Load key "/root/.ssh/id_rsa": invalid format
#13 1.425 git@gitlab.com: Permission denied (publickey,keyboard-interactive).
#13 1.426 fatal: Could not read from remote repository.
#13 1.426
#13 1.426 Please make sure you have the correct access rights
#13 1.426 and the repository exists.
#13 1.428 WARNING: Discarding git+ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0. Command errored out with exit status 128: git clone -q 'ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0' /tmp/pip-req-build-ck2o3z6p Check the logs for full command output.
#13 1.428 ERROR: Command errored out with exit status 128: git clone -q 'ssh://****@gitlab.com/organization/viiaa/abc_xx.git@v19.0' /tmp/pip-req-build-ck2o3z6p Check the logs for full command output.
------
executor failed running [/bin/sh -c pip install git+ssh://git@gitlab.com/organization/viiaa/abc_xx.git@v19.0]: exit code: 1
我已经将我的公钥添加到gitlab 配置文件密钥
解决方案
RUN pip install -r ./private_requirements.txt
尝试git+ssh://git@gitlab.com/organization/viiaa/abc_xx.git@v19.0
从容器内部访问您的。
但是容器无权访问您的 ssh 密钥!
您可以将您的私钥复制到 docker 容器中——出于安全原因,不建议这样做。
但是 docker 不支持在构建步骤中挂载,因此转发 ssh 密钥很棘手,但这是可能的。
请参阅SO:SSH agent forwarding during docker build 中的答案或Dan Pav
的另一个答案
推荐阅读
- tensorflow - MaskRCNN 转成 pb 文件
- python - 无法使用烧瓶邮件python将附件添加到邮件
- python-3.x - 如何找到在 python 中加载应用程序所需的时间?
- angular - 从 Angular 应用程序访问 YouTube API 时,gapi.client.youtube 未定义
- reactjs - 反应网格布局错误:
未安装在 DragStart 上 - python - 在长字符串中搜索关键字后的数字
- flutter - 标记未在谷歌地图上显示
- authentication - 为同一个 kuzzle 帐户处理多个 oauth 策略
- php - 当我在单个 AWS 实例中运行两个 Wordpress 站点时,网站无法加载
- java - 如何使用流 API 从 java 中的对象列表中删除重复项