<@ULVA73B9P> I run prefect on docker with docker t...
# ask-marvin
o
@Marvin I run prefect on docker with docker type worker pools, so that my docker workers create containers for running flows. All hosted locally. My question is, if my flow contains subflows, will they be in the same container as the parent? Or will they create new containers for the children?
m
thought for 101.1 seconds
Great question. In Prefect 3.x with a Docker work pool: - If you call a subflow directly (e.g.,
child_flow()
inside
parent_flow()
), the subflow runs in the same process and the same container as the parent. It creates a nested flow run in the UI but does not provision new infrastructure. - If you trigger a child via a deployment (e.g.,
run_deployment("child/deploy-name", ...)
), it creates a separate flow run that is picked up by a worker. With a Docker work pool, that means a new container will be started for the child run. By default it appears as a subflow in the UI (
as_subflow=True
), but it’s still a separate container. Helpful links: - Run deployments from a flow (run_deployment) - Serving flows with Docker workers - Workflow design patterns and subflows If you want everything to stay in one container, call the child flow directly. If you want isolation/parallelism or different infra for children, use
run_deployment
. Happy to share a small example if helpful.