Reputation: 181
When I build a docker image with command line:
docker build -t x .
I can see the process log in terminal.
But with the python API, it doesnt't show anything.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import docker
import os
route = os.path.dirname(os.path.abspath(__file__))
client = docker.from_env()
client.images.build(
path=route,
tag="al3x609/nvnc:latest",
rm=True
)
How can I see it in realtime?
Upvotes: 0
Views: 677
Reputation: 2113
According to the API the build returns:
Returns: The first item is the Image object for the image that was build. The second item is a generator of the build logs as JSON-decoded objects
Try something like:
(imageObj, buildlog) = client.images.build(
[...]
Then you can iterate throuhg buildlog:
for logline in buildlog:
print logline
Upvotes: 1