使用docker-compose通过ssh通过私有仓库构建映像时,主机密钥验证失败

时间:2019-06-05 10:10:17

标签: docker ssh docker-compose dockerpy

在我的docker-compose.yml内,我正在使用ssh地址上下文来构建Docker映像。

ui:
    build:
      context: git@my.git.host:ui/ui.git
      dockerfile: Dockerfile.prod
    container_name: ui
    ports:
      - "4200:4200"
    command: ember serve

跑步docker-compose build ui给我:

compose.cli.verbose_proxy.proxy_callable: docker build -> <generator object APIClient._stream_helper at 0x7faa8bc107d8>
ERROR: compose.cli.errors.log_api_error: error fetching: Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

如果我使用docker build来构建映像,则它可以正常工作

docker build git@my.git.host:ui/ui.git -f Dockerfile.prod

我的情境

compose.cli.command.get_client: docker-compose version 1.21.0, build unknown
docker-py version: 4.0.1
CPython version: 3.6.7
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018

最新编辑:
我设法使用docker pip重现了问题

import docker
client = docker.APIClient()
log = client.build(path="git@my.git.host:ui/ui.git", dockerfile="Dockerfile.prod")
for chunk in log:
  print(loc)

输出:

docker.errors.APIError: 500 Server Error: Internal Server Error ("error fetching: Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
: exit status 128")

0 个答案:

没有答案