Docker Community Forums

Share and learn in the Docker community.

Get docker container logs via python SDK asynchronously

All the examples I’ve found of using the Python Docker SDK to retrieve container logs is of the following:

client = docker.APIClient(base_url='tcp://localhost:2375')
for log in client.logs('my_container', stdout=True, stream=True):

Is there a way to get docker container logs asynchronously?
I’m looking for something like this:

while True:
    line = await client.logs('my_container', stdout=True, stream=True)
    await asyncio.sleep(1)