我正在尝试使用 docker api python 客户端从 GitHub 存储库构建 docker 映像。
这是我尝试过的: 来自views.py
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = TarFromGithubForm(post_data)
if form.is_valid():
deployment = gitHubModel()
deployment.name = form.cleaned_data['name']
deployment.user = request.user
deployment.archive = form.cleaned_data['archive']
dpath = deployment.archive
print(deployment.archive)
deployment.save()
tag = deployment.name.lower()
client = docker.from_env()
client.images.build(path=dpath, tag=tag)
messages.success(request, 'Your deployment from github repository has been created successfully!')
return HttpResponseRedirect(reverse('users:deployments:repo'))
在存档输入字段中,用户将提供 github 存储库 url。
它抛出一个错误:
APIError at /user/deployment/new/github 500 服务器错误:内部服务器错误(“错误检测远程https://github.com/Abdul-Rehman-yousaf/testing的内容类型:不支持的内容类型”text/html; charset=utf-8"") 请求方法:POST 请求 URL: http: //127.0.0.1 :8000/user/deployment/new/github Django 版本:1.11.3 异常类型:APIError 异常值:
500 服务器错误:内部服务器错误(“错误检测远程https://github.com/Abdul-Rehman-yousaf/testing的内容类型:不支持的 Content-Type "text/html; charset=utf-8"") 异常位置:/Users/abdul/IstioVirEnv/lib/python3.6/site-packages/docker/errors.py in create_api_error_from_http_exception,第 31 行 Python 可执行文件:/Users/abdul/IstioVirEnv/bin/python Python 版本:3.6.1