question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker buildimage intermittently builds image

See original GitHub issue

Hello, I am playing around with prefect and trying to use the buildimage for docker

from prefect import task, Flow
from prefect.tasks.docker import images


@task
def build_image():
    images.BuildImage(path='.').run()


with Flow("ETL") as flow:
    e = build_image()

flow.run()
[2019-07-16 19:36:37,341] INFO - prefect.FlowRunner | Beginning Flow run for 'ETL'
[2019-07-16 19:36:37,341] INFO - prefect.FlowRunner | Starting flow run.
[2019-07-16 19:36:37,342] INFO - prefect.TaskRunner | Task 'build_image': Starting task run...
[2019-07-16 19:36:41,274] INFO - prefect.TaskRunner | Task 'build_image': finished task run for task with final state: 'Success'
[2019-07-16 19:36:41,275] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded

I noticed that this intermittently builds an image once about ever 4-5 times I run it. Anyone have an idea what is going on?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richard-avelarcommented, Jul 17, 2019

Sounds good to me! Thanks for prompt feedback!

0reactions
cicdwcommented, Jul 17, 2019

Great!

So I have a guess here -> it’s possible that client.build is an asynchronous / deferred call of some kind, and whenever the Prefect Task exits it prevents the build from actually occurring. What we should do is update the Prefect Task to actually iterate over the client.build generator to ensure it completes before returning from the Task.

In the meantime, I recommend you implement a custom Task like so:

import docker


@task
def build_image(path):
    client = docker.APIClient(base_url="unix:///var/run/docker.sock", version="auto")
    client.build(path=path, tag=None, nocache=False, rm=True, forcerm=False)
    response = [line for line in client.build(path=".", tag=None, nocache=False, rm=True, forcerm=False)]
    return 

And I’d bet this works. Looks like I need to audit our Docker Tasks for this behavior!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a base image - Docker Documentation
You can use Docker's reserved, minimal image, scratch , as a starting point for building containers. Using the scratch “image” signals to the...
Read more >
React Docker Image Build Takes too long time. I need to fix this
I have run through the azure DevOps pipeline build. Logs it shows for React Image Build is mentioned as below. There are warnings...
Read more >
Use Docker to build Docker images - GitLab Docs
Docker -in-Docker with TLS disabled in the Docker executor. Sometimes you might have legitimate reasons to disable TLS. For example, you have no ......
Read more >
Building multi-architecture Docker images for Intel and ARM
The image runs very slowly and sometimes hangs or crashes. Clearly, QEMU-based emulation does not work well. Let's now look at how to...
Read more >
How to understand building images with docker-compose
Building docker images allow you to leverage other's images and repurpose them for ... You can sometimes skip the extra step of docker-compose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found