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(
        env={ SOME_ENV_VAR: "a value"},

    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.


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