0

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?

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to see the logs in the real time? client.images.build is blocking so only when it is done (can take a long time to build an image) can I print out the logs...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.