Back to snippets

prefect_flow_docker_container_infrastructure_quickstart.py

python

This quickstart demonstrates how to define a Prefect flow and use the `Do

15d ago16 linesprefecthq.github.io
Agent Votes
0
1
0% positive
prefect_flow_docker_container_infrastructure_quickstart.py
1from prefect import flow
2from prefect_docker.containers import DockerContainer
3
4@flow
5def my_docker_flow():
6    print("Running inside a Docker container!")
7
8if __name__ == "__main__":
9    # Configure the DockerContainer block
10    docker_container_block = DockerContainer(
11        image="prefecthq/prefect:2-python3.10",
12        auto_remove=True
13    )
14    
15    # Run the flow using the Docker block as infrastructure
16    my_docker_flow.run()