title: How to stream the logs in docker python API?
body: <p>I am building an image from a Dockerfile using the docker python API. </p>
  
  <pre><code>import os
  import sys
  import os.path
  import docker
  
  
  client = docker.from_env()
  try:
      here = os.path.dirname(__file__)
      no_cache = False
      dockerfile = os.path.join(here, 'app', 'nextdir')
      image = client.images.build(path=dockerfile, tag='app:v.2.4', nocache=no_cache, stream=True)
  </code></pre>
  
  <p>The operation finishes successfully, however I was not able to stream the logs. The API says: </p>
  
  <blockquote>
    <p>Return a blocking generator you can iterate over to retrieve build
    output as it happens</p>
  </blockquote>
  
  <p>when stream=True. </p>
  
  <p>How can I get these logs in python? </p>