How can I run my flow in a Docker container with a custom image?

Prefect 2.0

A custom image can be specified on the DeploymentSpec using the flow_runner keyword argument:

from prefect.flow_runners import DockerFlowRunner
from prefect.deployments import DeploymentSpec

    # replace "prefecthq/prefect:2.0" by your custom image 

Prefect 1.0

A custom image can be set as part of a run configuration:

from prefect.run_configs import DockerRun
from prefect import Flow

with Flow("flow_name", run_config=DockerRun(image="prefecthq/prefect:1.0"),) as flow: