私はdocker api python clientを使ってGitHubリポジトリからdockerイメージを構築しようとしています。ここで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 Server Error: Internal Server Error ("error detecting content type for remote https://github.com/Abdul-Rehman-yousaf/testing : unsupported Content-Type "text/html; charset=utf-8"") Request Method: POST Request URL: http://127.0.0.1:8000/user/deployment/new/github Django Version: 1.11.3 Exception Type: APIError Exception Value:
500 Server Error: Internal Server Error ("error detecting content type for remote https://github.com/Abdul-Rehman-yousaf/testing : unsupported Content-Type "text/html; charset=utf-8"") Exception Location: /Users/abdul/IstioVirEnv/lib/python3.6/site-packages/docker/errors.py in create_api_error_from_http_exception, line 31 Python Executable: /Users/abdul/IstioVirEnv/bin/python Python Version: 3.6.1
IリポジトリURLを次のように渡します: 'https://github.com/Abdul-Rehman-yousaf/testing 'とdockerfileはルートにあります –
ユーザーは、このリポジトリのルートにdockefileがあるメインリポジトリURLの代わりにdockerfile urlを渡す必要がありますか? –
メインgithubリポジトリへのhttpリクエストの作成は、git repoを使う正しい方法ではないので、pythonリクエストのようなhttpリクエストにメインリポジトリを渡すと、トラックバックから見たように[text/html]その場合はgithub apiを使ってレポをクローンし、レポをクローンした後でDockerfileにコードを渡していることを確認してください。 – misraX