2017-07-29 14 views
0

私は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

答えて

0

detecting content type for remoteunsupported Content-Type "text/html; charset=utf-8""はあなたが右のURLを渡されていることを確認していますか?あなたは右のURLを渡していることを確認するためにwgetを使用して簡単なHTTPリクエストを行うことができますhttps://raw.githubusercontent.com/Abdul-Rehman-yousaf/testing/master/Dockerfile

:このケースでは、あなたがDockerfileをしたい場合には、になります

wget https://raw.githubusercontent.com/Abdul-Rehman yousaf/testing/master/Dockerfile

そうに思えますあなたが間違ったURLを渡している、もう一つの方法は、リポジトリをクローンし、コードをDockerfileに渡すことです。コンテナに希望のファイルをコピーするなどの処理が行われます。

+0

IリポジトリURLを次のように渡します: 'https://github.com/Abdul-Rehman-yousaf/testing 'とdockerfileはルートにあります –

+0

ユーザーは、このリポジトリのルートにdockefileがあるメインリポジトリURLの代わりにdockerfile urlを渡す必要がありますか? –

+0

メインgithubリポジトリへのhttpリクエストの作成は、git repoを使う正しい方法ではないので、pythonリクエストのようなhttpリクエストにメインリポジトリを渡すと、トラックバックから見たように[text/html]その場合はgithub apiを使ってレポをクローンし、レポをクローンした後でDockerfileにコードを渡していることを確認してください。 – misraX

関連する問題