title: Build Docker image from GitHub repository
body: <p>I'm trying to build docker image from a GitHub repository using docker api python client.</p>
  
  <p>Here's what I have tried:
  <strong>From views.py</strong></p>
  
  <pre><code>        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'))
  </code></pre>
  
  <p>Here in archive input field user will provide github repository url.</p>
  
  <p>it throws an error:</p>
  
  <blockquote>
    <p>APIError at /user/deployment/new/github
    500 Server Error: Internal Server Error ("error detecting content type for remote <a href="https://github.com/Abdul-Rehman-yousaf/testing" rel="nofollow noreferrer">https://github.com/Abdul-Rehman-yousaf/testing</a>: unsupported Content-Type "text/html; charset=utf-8"")
    Request Method: POST
    Request URL:    <a href="http://127.0.0.1:8000/user/deployment/new/github" rel="nofollow noreferrer">http://127.0.0.1:8000/user/deployment/new/github</a>
    Django Version: 1.11.3
    Exception Type: APIError
    Exception Value:<br>
    500 Server Error: Internal Server Error ("error detecting content type for remote <a href="https://github.com/Abdul-Rehman-yousaf/testing" rel="nofollow noreferrer">https://github.com/Abdul-Rehman-yousaf/testing</a>: 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</p>
  </blockquote>