Handle Logging inside of DockerContainer

Is there a way to get logs and save them to a variable with DockerContainer? I have a docker container that runs a command that returns a JSON object, that I would like to handle later. I cant find a way to do this with Prefect2. With Prefect1 I could use “GetContainerLogs”.

registry = DockerRegistry.load("my-registry-block-name-from-prefect")

    dockerContainer = DockerContainer(
        image='some-image',
        image_registry=registry,
        name="container-name",
        command=cmd,
        env={ SOME_ENV_VAR: "a value"},
        stream_output=True,
    )

    dockerResult = dockerContainer.run()

stream_output confirms that the JSON result is occurring. But I do not see a way to return that to my flow for subsequent tasks.

Thanks!

1 Like

Gotcha – this is something we will enable by a Docker collection GitHub - PrefectHQ/prefect-docker: Prefect integrations for working with Docker

You can check out the collection from Brad here: GitHub - limx0/prefect-docker