<@ULVA73B9P> how do I get the logs from the docker...
# marvin-in-the-wild
v
@Marvin how do I get the logs from the docker container (so I can pass data pack?): @task(name="Parse Jora Jobs", retries=0, log_prints=True) def run_job_parser(): docker_container_block = DockerContainer.load("mediariot-docker-parser") container_result = docker_container_block.run() There is nothing in the container_result except this:
Copy code
{
  "identifier": "<http+docker://localhost:2>d588341dbd754ab477b868ae19068c250004503fc7fa8539836dd35be4643a7",
  "status_code": 0
}
There is no docker_container_block.get_docker_container_logs() function
m
It seems there is no method
get_docker_container_logs()
directly available on the
DockerContainer
block, but the functionality to retrieve logs from a Docker container is indeed possible. Here's how you can do it using the
get_docker_container_logs
method. First, you need the container ID to pull the logs from:
Copy code
python
from prefect import task
from prefect_docker.containers import get_docker_container_logs

@task(name="Parse Jora Jobs", retries=0, log_prints=True)
def run_job_parser():
    docker_container_block = DockerContainer.load("mediariot-docker-parser")
    container_result = docker_container_block.run()
    container_id = container_result.identifier.split('d')[-1]  # Extract container ID
    logs = get_docker_container_logs(container_id)
    print(logs)
The
get_docker_container_logs
function is async, so ensure your flow handles async/await appropriately if needed. For more details, you can refer to the Prefect documentation: https://docs.prefect.io/latest/integrations/prefect-docker/containers/ If you need any more help, please let me know!