【发布时间】:2019-01-04 22:56:54
【问题描述】:
TL;DR
有什么方法可以让 docker-compose 与 TFS Git URI 一起工作?
我编写了一个简单的 docker-compose.yml,它从包含 dockerfile 的存储库中提取并构建图像。
version: '3.4'
services:
ubuntu:
image: ubuntu-fromrepo
build:
context: https://github.com/dockerfile/ubuntu.git
dockerfile: Dockerfile
当你运行它时:
docker-compose up --build
它会自动拉取 git 仓库(master 分支),构建 ubuntu 镜像并运行它。
我在 TFS 上有一个存储库,其中包含一个 dockerfile,当您手动拉取并运行它时,它就可以工作。因此,git clone ... 克隆存储库,docker build . 构建映像,然后 docker run -it ubuntu:14.04(例如在 TFS 中提取与上面相同的存储库)。
但是,我上面使用的 docker-compose 方法不起作用,因为 TFS 的 Git URI 无法解析。它需要一个 HTTPS Git URI(“https://server-name/repository-name.git”),但在 TFS 中,Git URI 的格式为(“https ://server-name/tfs/Default/project-name/_git/repository-name")。
docker-compose 无法解析此 URI 并输出此错误:
服务 '...' 未能构建:{'message': '错误下载远程上下文 http://.../tfs/Default/.../_git/...: 无法 GET http://.../tfs/Default/.../_git/... 状态为 401 Unauthorized: \r\n .. .
HTML 只是一个错误页面,错误代码如下:
完整的 HTML here.
TF400813:资源不可用于匿名访问。需要客户端身份验证。
有什么方法可以让 docker-compose 与 TFS Git URI 一起工作?
更新:
我已经用标记化的 URI 对其进行了测试:
git clone https://token@servername/tfs/Default/projectname/_git/repositoryname
这有效,但在 docker-compose.yml 文件中使用相同的 URI 无效 - 会出现此错误:
ERROR: compose.cli.errors.log_api_error: error detecting content type for remote http://...@.../tfs/Default/.../_git/...: unsupported Content-Type "text/html; charset=utf-8"`
我认为这只是在 TFS 上为不可访问的资源返回错误页面?
【问题讨论】:
-
该错误消息的其余部分是什么?似乎不太可能是 URL,似乎更有可能是无法通过身份验证。
-
更新了问题并在 pastebin 中添加了指向 HTML 错误页面的链接
-
嗯。
username:pat真的应该是正确的格式。您的克隆测试是否有可能是误报?您可能在本地安装了凭证助手吗?
标签: git docker tfs docker-compose