Learn how to serve a flow in a long-lived Docker container
.serve
method allows you to easily elevate a flow to a deployment, listening for scheduled work to execute as a local process.
However, this “local” process does not need to be on your local machine. In this example we show how to run a flow in Docker container on your local machine, but you could use a Docker container on any machine that has Docker installed.
Dockerfile
that packages up your flow code and dependencies into a container imageDockerfile
.
pip
, the image is built in about 20 seconds, and using uv
, the image is built in about 3 seconds.You can learn more about using uv
in the Astral documentation.docker build
command and the -t
flag to specify a name for the image.
.env
file:
CONTAINER ID
as we’ll need it to view logs.